3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $d1 = new \DateTime('2017-07-05T01:00:00+02:00'); $d2 = new \DateTime('2017-07-04T18:00:00-05:00'); var_dump($d1); var_dump($d2); var_dump($diff = $d1->diff($d2)); var_dump($diff->format('%a'));
Output for 7.1.0 - 7.2.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-05 01:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+02:00" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-05:00" } object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(0) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } string(1) "0"
Output for 5.6.30, 7.0.0 - 7.0.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-05 01:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+02:00" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-05:00" } object(DateInterval)#3 (15) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(0) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } string(1) "0"
Output for hhvm-3.15.4 - 3.22.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-05 01:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+02:00" } object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 18:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-05:00" } object(DateInterval)#3 (0) { } string(1) "0"