Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: finding the sum of times
03-04-2010, 04:05 PM #1
- Join Date
- Jun 2002
- Thanked 5 Times in 5 Posts
finding the sum of times
I'm after some thoughts on how to go about adding up times. The times are all in the format of HH:MM:SS
that would be 10 hours, 20 minutes and 2 seconds.. now say I have
I need to add all those up...
Does anyone have any help or pointers to functions that can help with this?
03-04-2010, 04:10 PM #2
Add up the hours, minutes, and seconds individually. If the times are stored as strings, use the explode function to split each time up.
After you've done that, you'll have to look at the seconds. If it's more than 59, you'll need to increment your minutes by 1. If it's more than 119, you'll haev to increment your minutes by 2, etc. Just divide by 60 and round.
The same is true for your minutes...if you have too many minutes, you'll need to increment your hours value.
That should get you going in the right direction. The code shouldn't be that complex in the end.
Users who have thanked bacterozoid for this post:
sir pannels (03-18-2010)