Calculate Time Lapsed between two dates.

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
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Calculate Time Lapsed between two dates.

Post 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...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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...
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

ok Mr.Guru, why don't you post some mean and lean code instead of nothing.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post 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.
Post Reply