> can anybody help me how to count seconds, minutes and hours in php?
> I want to sum values like 03:35, 02:31, 04:59, etc. and show the
> results in minutes.
Here's how I would try to do it:
<?php
$times = array("03:35", "02:31", "04:59");
$hours = 0;
$minutes = 0;
$seconds = 0;
while (list(,$time) = each($times)){
$minsec = explode(':', $time);
$minutes += $minsec[0];
$seconds += $minsec[1];
}
$minutes += (int) ($seconds/60);
$seconds = $seconds % 60;
$hours = (int) ($minutes/60);
$minutes = $minutes % 60;
if ($hours){
echo "$hours hours, ";
}
echo "$minutes minutes, $seconds seconds<BR>\n";
?>
There's probably several other ways to do it. YMMV.
Don't miss the Zend Web Store's Grand Opening on January 23, 2001!
http://www.zend.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]