Page 1 of 1

The time between two dates

Posted: Tue Aug 05, 2008 7:29 am
by chorage
Hello there

I'm working on a sorta calendar project to be used with studies. It's a pretty simple PHP program, that lists some appointments and the status of those. The whole focus is to keep track of my deadlines. I was thinking it would be really cool, if i could make the program tell me how many days there is from the current date till deadline.

In short:

Is there a way to compare 2 dates (deadline and localtime) and output the time between them? Be it seconds, minutes whatever.

Thanks in advance

Chorage

Re: The time between two dates

Posted: Tue Aug 05, 2008 7:30 am
by jaoudestudios
If you store the deadline date using php function time() and compare it with time() now then yes you can do anything!

Re: The time between two dates

Posted: Tue Aug 05, 2008 8:07 am
by chorage
Thanks a bunch, that worked for me :D

$timedifference = strtotime($deadline) - time();

or in days: $timedifference = (strtotime($deadline) - time())/3600/24;