3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Get an interval between 1st January and 14th January $diff1 = (new DateTimeImmutable('2019-01-01'))->diff(new DateTimeImmutable('2019-01-14')); // Get another interval, but this time an extra day on the end $diff2 = (new DateTimeImmutable('2019-01-01'))->diff(new DateTimeImmutable('2019-01-15')); // Check if the first interval is shorter than the second var_dump($diff1 < $diff2); // Oh, that's weird... // Let's peek inside the two intervals var_export($diff1, true); var_export($diff2, true); // Now let's check again var_dump($diff1 < $diff2);
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Warning: Cannot compare DateInterval objects in /in/O8Okj on line 10 bool(false) Warning: Cannot compare DateInterval objects in /in/O8Okj on line 18 bool(false)
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
bool(false) bool(true)

preferences:
142.34 ms | 407 KiB | 5 Q