3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function time_diff($s) { $m = 0; $hr = 0; $d = 0; $td = "now"; if ($s > 59) { $m = (int)($s/60); $s = $s-($m*60); // sec left over $td = "$m min"; } if ($m > 59) { $hr = (int)($m / 60); $m = $m - ($hr*60); // min left over $td = "$hr hr"; if ($hr > 1) { $td .= "s"; } if ($m > 0) { $td .= ", $m min"; } } if ($hr > 23) { $d = (int) ($hr / 24); $hr = $hr-($d*24); // hr left over $td = "$d day"; if ($d > 1) { $td .= "s"; } if ($d < 3) { if ($hr > 0) { $td .= ", $hr hr"; } if ($hr > 1) { $td .= "s"; } } } return $td; } $diffInSecs = strtotime('14:00') - strtotime('9:00'); $hours = $diffInSecs / 3600; echo $hours; echo "<br>"; echo time_diff($diffInSecs);
based on OTQfv
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
5<br>5 hrs
Output for hhvm-3.10.0

Process exited with code 153.