| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe to WebmasterWorld|
|Performing math with time|
Finding out elapsed time between two times
| 2:54 am on May 6, 2008 (gmt 0)|
I have to apply some math to time. Here's the deal.
Shifts have a starting time ($timestart) and an end time ($timeend), which are stored in the database as DATETIME.
I need to find out how much time has passed between $timestart and $timeend. It seems like a pretty straightforward thing to do, but I can't seem to Google out an answer.
Can I get a bit of help?
| 4:43 am on May 6, 2008 (gmt 0)|
Searching 'mysql datetime functions' in Google, the first link returns you some relevant results. I believe DATE_SUB() or DATEDIFF() are what you're looking for.
Hope this helps,
| 7:06 pm on May 6, 2008 (gmt 0)|
Cool, I'm checking it out right now.
I think, though, that I'm going to need them done in PHP. Does anyone know how?
| 7:51 pm on May 6, 2008 (gmt 0)|
The easiest way for me is to convert them to times (strtotime) and subtract the two. Then you have the number of seconds between them, which you can use any way you like.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2014 all rights reserved