Или вы просто идете прямо вперед; -)
<?php
$a = "00:00:12";
$b = "00:00:05";
function addTime($timeA, $timeB) {
$timeAcomponents = explode(":", $timeA);
$timeBcomponents = explode(":", $timeB);
$timeAinSeconds = $timeAcomponents[0]*60*60 + $timeAcomponents[1]*60 + $timeAcomponents[2];
$timeBinSeconds = $timeBcomponents[0]*60*60 + $timeBcomponents[1]*60 + $timeBcomponents[2];
$timeABinSeconds = $timeAinSeconds + $timeBinSeconds;
$timeABsec = $timeABinSeconds % 60;
$timeABmin = (($timeABinSeconds - $timeABsec) / 60) % 60;
$timeABh = ($timeABinSeconds - $timeABsec - $timeABmin*60) / 60 / 60;
return str_pad((int) $timeABh,2,"0",STR_PAD_LEFT).":"
.str_pad((int) $timeABmin,2,"0",STR_PAD_LEFT).":"
.str_pad((int) $timeABsec,2,"0",STR_PAD_LEFT);
}
echo "Adding time variables:\n";
echo "$a + $b = ".addTime($a, $b);
?>