3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $seconds = 2434; $h = $seconds / 3600 % 24; $m = $seconds / 60 % 60; $s = $seconds % 60; $hours = '00'; $minutes = '00'; $seconds = '00'; if ($h > 0){ if (strlen(strval($h)) == 1){ $hours = '0'.strval($h); } } if ($m > 0){ if (strlen(strval($m)) == 1){ $minutes = '0'.strval($m); } } if ($s > 0){ if (strlen(strval($s)) == 1){ $seconds = '0'.strval($s); } } $time = $hours.":".$minutes.":".$seconds; echo "\$h: ", $h, " \n"; echo "\$m: ", $m, " \n"; echo "\$s: ", $s, " \n"; echo $time;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
$h: 0 $m: 40 $s: 34 00:00:00