3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function oldFormatSeconds($ss) { $result = ''; $s = $ss % 60; $m = floor(($ss % 3600) / 60); $h = floor(($ss % 86400) / 3600); $d = floor(($ss % 2592000) / 86400); if ($d > 0) { $result .= $d . 'd, '; } if ($h > 0) { $result .= $h . 'h '; } if ($m > 0 || $s > 0) { $result .= $m . 'm '; } if ($s > 0) { $result .= $s . 's '; } return $result; } function formatSeconds($s) { return gmdate("H i s\s", 1000); } echo oldFormatSeconds(1000); echo "\n"; echo formatSeconds(1000);
based on JEfFD
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
16m 40s 00 16 40s