Page 1 of 1

[SOLVED]Easy problem

Posted: Tue Nov 09, 2004 4:39 pm
by Deemo
Im feeling really stupid, but it seems i have been stumped

what im trying to in one of my programs is like a "count up" type thing. basicly, in the file itself, it will hate a date, lets say the format is

Code: Select all

//MM/DD/YY
$date="08/04/04";
basicly what i want to be able to do is take todays date, and determine exactly how many days have passed since the given date.

Is there an easier way for me to set the date so conversion would be easier? and if not, could you lead me on the right course of solving this problem?

sounds easy to me, i dont know why i cant figure it out :(

thanks alot

Posted: Tue Nov 09, 2004 4:44 pm
by timvw
[php_man]strtotime[/php_man] does the magic :)


untested

Code: Select all

$date = strtotime("08/04/04");
$now = strtotime("now");
$diff = $now - $date;

$daysdiff = $diff / ( 60 * 60 * 24);

echo $daysdiff;

Posted: Tue Nov 09, 2004 5:55 pm
by Deemo
thank you very much! it works perfectly :)