3v4l.org

run code in 500+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); $date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, '2023-11-22T11:52:00+01:00'); $now = new DateTime('2023-11-22T10:52:03', null); var_dump($date->diff($now));
Output for 8.2.0 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
object(DateInterval)#3 (10) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(3) ["f"]=> float(0) ["invert"]=> int(0) ["days"]=> int(0) ["from_string"]=> bool(false) }
Output for 8.1.10 - 8.1.34, 8.0.1 - 8.0.30
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(3) ["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) }
Output for 8.1.0 - 8.1.9
object(DateInterval)#3 (16) { ["y"]=> int(-1) ["m"]=> int(11) ["d"]=> int(31) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(3) ["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) }

preferences:
32.11 ms | 1175 KiB | 6 Q