FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


using dates in php





Talk2Tom11
I have two questions...

first... when I use this code to format a date...

echo date("m/d/Y", $date);

it returns the date 12/31/1969... no matter what $date is. Sad

anyone know another way i can format a date.


Second. how do I add one date to $date.

i know how to do like tomorrow...

$tomorrow = mktime(0, 0, 0, date("m"), date("d")+1, date("y"));


but i want it off of a be determined $date
Diablosblizz
Have you reviewed PHP date formats?

http://ca.php.net/date

Example of a date code:

Code:

<?php
$date = date(j,F);

echo $date
?>



Just an example, try putting your first question into a variable like I put above.
JJGY
It sounds like the issue is simply with your server if the $date variable returns anything aside from an error. Are you sure that you didn't override the value at some other point in your script?
vinx_18
The date might contain a US English date format

Try this:

Quote:

$timestamp = strtotime($date));
$date = date('m/d/Y', $timestamp);
powers1983
Are you sure $date contains a correct timestamp?

As in:
Code:

$date=time();
echo date("m/d/Y", $date);

If you want to display tomorrows date you can just do:
Code:

$date=time();
$tomorrow=$date + 24*60*60;
echo date("m/d/Y", $tomorrow);
Talk2Tom11
For some reason I feel i wasn't very clear...


$date for example equals 10/21/08...

and i want to then display one day after $date... which would be 10/22/08.

I know how to display "today", and "tomorrow"...

But i want to display the day after whatever value $date has.
powers1983
Ok then. The date funtion needs to be sent a timestamp - which is a big integer equal to the number of seconds passed since 1st Jan 1970.

So you'd have to combine the previous 2 posts:

Code:

$timestamp = strtotime($date));
$tomorrow=$timestamp + 24*60*60;
echo date("m/d/Y", $tomorrow);
manum
above post has ur answer as well as mine thanx buddy
Talk2Tom11
thank you very much for all of the help! Smile
Related topics
php mail and BCC
php include path
INSTALL PHP
Anyone Using Simple PHP Blog
[php] can't display rss feeds using rss2html.php
zeroboad php
Rebuilt site using php, google seems confused
Php mail function
Hex editing in PHP
WP (blog) xmlrpc.php gives a "403 forbidden", no m
What is a good php mvc framework
PHP Mail
Im using apahe,php, and mysql and dreamweaver (HELP)
Prewritten PHP sha256/512?
How do you Create a New Database using a php script?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.