3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function timeBetweenTwoTimes($t1, $t2){ $t1 = new DateTime($t1); $t2 = new DateTime($t2); $sinceThen = $t2->diff($t1); $h = $sinceThen->h; $m = $sinceThen->i; $s = $sinceThen->s; if($h < 10){ $h = "0".$h; } if($m < 10){ $m = "0".$m; } if($s < 10){ $s = "0".$s; } return $h .':'.$m.':'.$s; } echo timeBetweenTwoTimes('9:00:00','12:00:00');
based on SR1jB
Output for 5.3.19 - 7.2.0
03:00:00