3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date1 = new DateTime(time()); $date2 = clone $date1; $interval = new DateInterval('PT1H5M'); $date2->add($interval); $diff = $date2->diff($date1); echo $diff->format('%i') /* lots of adding up to get complete interval as minutes this way */; echo ' minutes'; echo PHP_EOL; var_dump($diff); echo PHP_EOL; echo ($date2->getTimestamp() - $date1->getTimestamp()) / 60; echo ' minutes';
based on JglOB
Output for 7.1.0 - 7.2.0
5 minutes object(DateInterval)#4 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(1) ["i"]=> int(5) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(1) ["days"]=> int(0) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 65 minutes
Output for 5.4.17 - 7.0.20
5 minutes object(DateInterval)#4 (15) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(1) ["i"]=> int(5) ["s"]=> int(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(1) ["days"]=> int(0) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 65 minutes
Output for 5.4.0 - 5.4.16
5 minutes object(DateInterval)#4 (8) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(1) ["i"]=> int(5) ["s"]=> int(0) ["invert"]=> int(1) ["days"]=> int(0) } 65 minutes