[SOLVED]Easy problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

[SOLVED]Easy problem

Post 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
Last edited by Deemo on Tue Nov 09, 2004 5:55 pm, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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;
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

thank you very much! it works perfectly :)
Post Reply