Page 1 of 1

Adding Time

Posted: Tue Sep 13, 2005 1:00 am
by vivekjain
Hi,
Can you tell how do I add time, i.e.

Start time ----------------- End Time ---------------- ---- Total

12:00:09 PM ---------------- 12:07:59 PM ---------------- 0:07:50

12:10:32 PM ---------------- 2:25:04 PM ---------------- 1:34:32



There are many more records and I want to add the Totals, including the seconds, minutes and hours.

Can anyone suggest how I could do that using PHP.

Thanks

Posted: Tue Sep 13, 2005 1:11 am
by 127.0.0.1
Depending on the way you require this to work you may be able to use the function mktime.

http://uk.php.net/mktime

Posted: Tue Sep 13, 2005 1:16 am
by feyd
convert them to unix timestamps, add them up, divide it back out into the apporpriate format if you are using php to do it. If you're using a database, they often have date/time interaction functions. For instance, MySQL has ADDTIME(). Note that you shouldn't use 12 hour format times with MySQL..