I came across a similar problem, and wrote a small function to convert times (formatted in a variety of ways) to seconds. It's obviously then trivial to add the seconds together.
function getSeconds($s) {
$s = str_replace('h',':',$s);
$s = str_replace(',','.',$s);
$a = explode(':',$s);
$n = count($a);
if ($n==1)
return $a[0]; //just seconds
if ($n==2)
return $a[1] + 60 * $a[0]; //minutes and seconds
if ($n==3)
return $a[2] + 60 * $a[1] + 3600 * $a[0]; //hours minutes and seconds
}
Works for the following formats:
12
12.34
12:34 (will assume mm:ss in this format)
12:34.56
12:34,56
12:34:56.78
12h34:56,78
TimeSpans instead. Or calc back to seconds since epoch en add/subtract those.strtotimewill give you a point in (absolute) time. You cannot add another absolute timestamp to that. If you are working with time durations,strtotimeis the wrong tool.