| Welcome to WebmasterWorld Guest from 184.108.40.206 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Pubcon Platinum Sponsor 2014|
|Performing math with time|
Finding out elapsed time between two times
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?
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,
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?
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.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved