I have the two times like this
2010-08-09 11:16:06
2010-08-09 11:19:12
I need to find out the time difference between these two dates and also I need to store difference between these two.For example here the difference is 00:03:02
And if the user again start the timer and stop it for example the second starting time is
2010-08-09 11:21:06
End time is 2010-08-09 11:22:12
I need to add this into the previous timer like 00:03:02
+00:01:06
and need to display total duration is 00:04:08
.
Ps:It may be starting and end time difference in days.
How can I do this?
Any help appreciated.
Asked
Active
Viewed 106 times
0

svk
- 4,513
- 18
- 63
- 100
-
possible duplicate of [how to calculate time difference in PHP](http://stackoverflow.com/questions/2920335/how-to-calculate-time-difference-in-php) and a [couple others](http://stackoverflow.com/search?q=time+difference+php) – Gordon Aug 19 '10 at 10:51
1 Answers
2
- Store the duration in seconds
- Use
strototime
to convert dates into timestamps - Use
date
to convert timestamps into dates - Calculate second differences by subtracting the timestamps
- Calculate offset timestamps by adding the second difference to their timestamps

Artefacto
- 96,375
- 17
- 202
- 225