3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function seconds_from_time($time) { list($h, $m, $s) = explode(':', $time); return ($h * 3600) + ($m * 60) + $s; } function time_from_seconds($seconds) { $h = floor($seconds / 3600); $m = floor(($seconds % 3600) / 60); $s = $seconds - ($h * 3600) - ($m * 60); return sprintf('%02d:%02d:%02d', $h, $m, $s); } echo seconds_from_time("18:27:31"); echo '<br />'; echo time_from_seconds(66451); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
66451<br />18:27:31