> I got a mysql database, where two of the fields of a table > record times as > CHAR(8) in the format hh:mm:ss
> I want to take this two times and get the difference between > them in seconds, for example 12:01:30 - 12:00:00 = 90 I > looked up at the doc in the php.net website and couldn't get > on how to do this... should I use the strtotime function? <?php function TimeDifference($SourceA, $SourceB) { $TimeA = explode(":", $SourceA); $TimeB = explode(":", $SourceB); $SecondsA = ($TimeA[0] * 60 * 60) + ($TimeA[1] * 60) + $TimeA[2]; $SecondsB = ($TimeB[0] * 60 * 60) + ($TimeB[1] * 60) + $TimeB[2]; $TimeDifference = $SecondsB - $SecondsA; return $TimeDifference; } $Start = "12:00:00"; $Stop = "12:01:30"; print "The time difference is " . TimeDifference($Start, $Stop) . " seconds.<br>"; ?> **************************************************************************** This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php