3v4l.org

run code in 300+ PHP versions simultaneously
<?php $diff = (new DateTimeImmutable('2021-09-01 UTC'))->diff(new DateTimeImmutable('2021-12-01 UTC')); var_dump($diff); $diff = (new DateTimeImmutable('2021-09-01 Asia/Tokyo'))->diff(new DateTimeImmutable('2021-12-01 Asia/Tokyo')); var_dump($diff);
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.24, 8.0.0 - 8.0.11
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(3) ["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(91) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } object(DateInterval)#4 (16) { ["y"]=> int(0) ["m"]=> int(2) ["d"]=> int(30) ["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(91) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) }

preferences:
79.57 ms | 404 KiB | 72 Q