3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime('2014-11-01 01:01:01'); $finish = new DateTime('2014-11-02 03:02:01'); $interval = $finish->diff($start); echo $interval->format('%H:%I:%S'), PHP_EOL; $star = '2014-11-01 01:01:01'; $finish = '2014-11-02 03:02:01'; $s = strtotime($star); $f = strtotime($finish); $e = $f-$s; echo sec2date($e); function sec2date($secs) { $sec = $secs%60; $jam = intval($secs/3600); $menit = intval($secs/60)%60; $sec = ($sec < 10)?"0$sec":"$sec"; $jam = ($jam < 10)?"0$jam":"$jam"; $menit = ($menit < 10) ? "0$menit" : "$menit"; return "$jam:$menit:$sec"; }
based on Pi7ca
Output for 5.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
02:01:00 26:01:00
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/evpST on line 6
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/evpST on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/evpST on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/evpST on line 3