Page 1 of 1

Calculate Time Lapsed between two dates.

Posted: Fri Jul 01, 2005 5:48 pm
by quadoc
I need to calculate time lapsed between two dates and return days, hours and minutes. (i.e. 4d 2hr 5m, 2hr 5m, 5m), does anyone has any simple script for this? Thanks...

Posted: Fri Jul 01, 2005 7:02 pm
by timvw
This question has been asked (and answered) too many times...

You probably already know you need to use http://www.php.net/strtotime to get some unixtimestamps and make the difference. Then it's only a matter of divide / and module % by 60 to find out the remainder...

Posted: Fri Jul 01, 2005 8:18 pm
by quadoc
ok Mr.Guru, why don't you post some mean and lean code instead of nothing.

Posted: Fri Jul 01, 2005 8:31 pm
by Chris Corbyn
quadoc wrote:ok Mr.Guru, why don't you post some mean and lean code instead of nothing.
People to don't come here to have code written for them... timvw actually gave the answer you needed and as mentioned it's been asked LOTS of times on the forum. We have a search feature so I suggest you search for "date difference" with "all terms" selected. There's plenty of posts like this...
viewtopic.php?t=32137&highlight=date+difference

Posted: Fri Jul 01, 2005 8:49 pm
by quadoc
You know I tried the search feature and it return nothing, that is why I'm asking. Besides most of the date scripts that I've seen are not helping me at all.