function sum_time() {
$i = 0;
foreach (func_get_args() as $time) {
sscanf($time, '%d:%d', $hour, $min);
$i += $hour * 60 + $min;
}
if ($h = floor($i / 60)) {
$i %= 60;
}
return sprintf('%02d:%02d', $h, $i);
}
// use example
echo sum_time('01:05', '00:02', '05:59'); # 07:06
function sum_time()
{
$totalSeconds = 0;
foreach (func_get_args() as $time)
{
sscanf($time, '%d:%d:%d', $hours, $minutes, $seconds);
$totalSeconds += ($hours * 60 * 60) + ($minutes * 60) + $seconds;
}
$hours = floor($totalSeconds / 3600);
$minutes = floor(($totalSeconds / 60) % 60);
$seconds = $totalSeconds % 60;
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
}
// use example
echo sum_time('01:05:37', '00:02:00', '05:59:59'); # 07:07:36