Page 1 of 1

How do I subtract 2 dates/times?

Posted: Fri Jan 20, 2006 2:56 am
by vigour
I have two dates with times like this:

Start date/time = 2006-01-01 08:12
End date/time = 2006-01-07 10:45

I want to take the End date/time and subtract Start date/time from it.
I want the results in days, hours and minutes.

Like this example:

4 days, 3 hours and 52 minutes.

How do I do that in PHP?

Posted: Fri Jan 20, 2006 5:35 am
by foobar
strtotime() and then subtract one from the other.
Note that your dates have to be in a standard format.

Posted: Fri Jan 20, 2006 8:09 am
by feyd
viewtopic.php?t=29341 may be of interest.