3v4l.org

run code in 300+ PHP versions simultaneously
<?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;
Output for 7.4.20, 8.0.11
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 7.4.23 - 7.4.24, 8.0.5 - 8.0.7, 8.0.9 - 8.0.10
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 7.4.7, 7.4.12 - 7.4.13, 7.4.21, 8.0.8
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 7.4.0, 8.0.0, 8.0.3
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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.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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 7.4.3 - 7.4.6, 7.4.8 - 7.4.11, 7.4.14 - 7.4.15, 7.4.22, 8.0.2
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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(6.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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 8.0.1
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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(5.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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 7.4.16
Warning: Cannot compare DateInterval objects in /in/3RhjI on line 11 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 12 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 13 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 21 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 22 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 24 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 25 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) } Warning: Cannot compare DateInterval objects in /in/3RhjI on line 29 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 30 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 32 bool(false) Warning: Cannot compare DateInterval objects in /in/3RhjI on line 33 bool(false)
Output for 7.2.18 - 7.2.19, 7.2.22, 7.3.1 - 7.3.2, 7.3.6, 7.3.10, 7.3.30
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.1.31, 7.1.33, 7.2.17, 7.2.25 - 7.2.29, 7.3.0, 7.3.4, 7.3.12, 7.3.21, 7.3.25, 7.3.27, 7.3.29
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(6.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.31, 7.3.5, 7.3.17, 7.3.26, 7.3.28
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.21, 7.2.24, 7.2.32, 7.3.11, 7.3.19 - 7.3.20, 7.3.23 - 7.3.24
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.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.30, 7.3.18
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.9E-5) ["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.26 - 7.1.29, 7.1.32, 7.2.20, 7.2.23, 7.2.33, 7.3.7 - 7.3.9, 7.3.16
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(5.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.3
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(1.4E-5) ["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.30, 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 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)

preferences:
120.72 ms | 402 KiB | 111 Q