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(date('r', $_SERVER['REQUEST_TIME']))); print_r($di2);
based on 5QMCq
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] => 7 [h] => 0 [i] => 22 [s] => 52 [f] => 0 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 68 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )
Output for 5.5.14 - 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] => 7 [h] => 0 [i] => 22 [s] => 52 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 68 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )
Output for 5.5.0 - 5.5.13
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] => 7 [h] => 0 [i] => 22 [s] => 52 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 68 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 )