3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dt1 = new DateTime('1 year ago'); $dt2 = new DateTime('yesterday'); $dt3 = new DateTime(); $longest = $dt1->diff($dt3); $shortest = $dt2->diff($dt3); $middle = $dt1->diff($dt2); var_dump($longest > $shortest); var_dump($longest > $middle); var_dump($longest < $shortest); $int15 = new DateInterval('P15D'); $int20 = new DateInterval('P20D'); $date = new DateTime(); $diff = $date->diff(new DateTime("+10 days")); var_dump($int15 < $diff); //should be false; var_dump($diff < $int15); //should be true; var_dump($int15 > $diff); //should be true; var_dump($diff > $int15); //should be false; var_dump($diff); var_dump($int15 < $diff); //should be false; var_dump($diff < $int15); //should be true; var_dump($int15 > $diff); //should be true; var_dump($diff > $int15); //should be false;
based on eRDcl
Output for 7.3.0beta1
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(4.0E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.3.0alpha1
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(8.0E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.2.6
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(9.0E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.2.0 - 7.2.5
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(3.0E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.1.20
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(7.0000000000001E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.1.7
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(4.0000000000001E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.1.6
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(2.9999999999995E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.1.5
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(4.0000000000005E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 7.1.0 - 7.1.1
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(4.9999999999998E-6) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (15) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(10) ["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(10) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } bool(true) bool(false) bool(false) bool(true)
Output for hhvm-3.15.4
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) object(DateInterval)#11 (0) { } bool(false) bool(false) bool(false) bool(false)