function add_time($time1,$time2){
$t1 = explode(":",$time1);
$t2 = explode(":",$time2);
for($x=0;$x<3;$x++){
$totals[] = intval($t1[$x]) + intval($t2[$x]);
}
$minsfromsecs = floor($totals[2]/60);
$secs = str_pad($totals[2] - $minsfromsecs * 60,2, '0', STR_PAD_LEFT);
$mins = $totals[1] + $minsfromsecs;
$hoursfrommins = floor($mins/60);
$mins = str_pad($mins - $hoursfrommins * 60,2, '0', STR_PAD_LEFT);
$hours = str_pad($totals[0] + $hoursfrommins,2, '0', STR_PAD_LEFT);
return "$hours:$mins:$secs";
}
$start = '00:00:57';
$finish = '00:59:05';
echo add_time($start,$finish);
works for me. It's a rush job, no doubt that it could be optimized though. Maybe better time functions I don't know about / forgot too.
diafol
Keep Smiling
10,647 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,509
Skill Endorsements: 57