3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function strToDuration($str) { sscanf($str, '%d:%d:%d', $hours, $minutes, $seconds); return $seconds + ($minutes * 60) + ($hours * 60 * 60); } function durationToStr($duration) { $hours = floor($duration / (60 * 60)); $seconds = $duration % (60 * 60); $minutes = floor($seconds / 60); $seconds %= 60; return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds); } $morning = '01:05:12'; $evening = '14:05:29'; echo durationToStr(strToDuration($morning) + strToDuration($evening));
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
15:10:41
Output for hhvm-3.10.0

Process exited with code 153.