3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $di = (new DateTime('2012-10-20'))->diff(new DateTime('2012-12-10')); print_r($di); print_r((new DateTime('2015-09-30'))->add($di)); $di2 = (new DateTime('2015-09-30'))->diff(new DateTime('2015-12-06 22:23:00')); print_r($di2);
based on J3AbP
Output for 7.1.0 - 7.2.0
DateInterval Object ( [y] => 0 [m] => 1 [d] => 20 [h] => 0 [i] => 0 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 51 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) DateTime Object ( [date] => 2015-11-19 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateInterval Object ( [y] => 0 [m] => 2 [d] => 6 [h] => 22 [i] => 23 [s] => 0 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 67 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )
Output for 5.4.30 - 7.0.20
DateInterval Object ( [y] => 0 [m] => 1 [d] => 20 [h] => 0 [i] => 0 [s] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 51 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) DateTime Object ( [date] => 2015-11-19 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateInterval Object ( [y] => 0 [m] => 2 [d] => 6 [h] => 22 [i] => 23 [s] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 67 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )
Output for 5.4.17 - 5.4.29
DateInterval Object ( [y] => 0 [m] => 1 [d] => 20 [h] => 0 [i] => 0 [s] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 51 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) DateTime Object ( [date] => 2015-11-19 00:00:00 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateInterval Object ( [y] => 0 [m] => 2 [d] => 6 [h] => 22 [i] => 23 [s] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 67 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )
Output for 5.4.10 - 5.4.16
DateInterval Object ( [y] => 0 [m] => 1 [d] => 20 [h] => 0 [i] => 0 [s] => 0 [invert] => 0 [days] => 51 ) DateTime Object ( [date] => 2015-11-19 00:00:00 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateInterval Object ( [y] => 0 [m] => 2 [d] => 6 [h] => 22 [i] => 23 [s] => 0 [invert] => 0 [days] => 67 )
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/s7cGd on line 3
Process exited with code 255.