...

View Full Version : finding the sum of times



sir pannels
03-04-2010, 04:05 PM
Hi there,

I'm after some thoughts on how to go about adding up times. The times are all in the format of HH:MM:SS

so ...

10:20:02

that would be 10 hours, 20 minutes and 2 seconds.. now say I have

10:20:02
02:10:42
13:21:11

I need to add all those up...

Does anyone have any help or pointers to functions that can help with this?

Many thanks

bacterozoid
03-04-2010, 04:10 PM
Add up the hours, minutes, and seconds individually. If the times are stored as strings, use the explode function to split each time up.

10:20:02
02:10:42
13:21:11
---------
25:41:55

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum