3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = new DateTime(); //$startDate = new DateTime("2017/6/24"); //$startDate->add(new DateInterval('P12M')); $startDate = new DateTime("2017/6/24"); $diff = $startDate->diff($date); var_dump($diff); $surplus = $diff->d > 0 ? 0 : 1; echo ($diff->y * 12 + $diff->m + $surplus); //echo $date->format('Y-m-d H:i:s'); //echo $startDate->format('Y-m-d H:i:s'); ?>
based on laX69
Output for 7.3.0beta1
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.002652) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.3.0alpha1
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.003361) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.2.11
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.002694) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.2.6
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.00204) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.20
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.003415) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.10
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.006604) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.9
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.005057) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.8
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.003996) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.7
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.005195) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.6
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.01715) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.5
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.02073) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.4
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.02726) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.3
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.2
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.019597) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.1
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.005012) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 7.1.0
object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["f"]=> float(0.00462) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.24
object(DateInterval)#3 (15) { ["y"]=> int(0) ["m"]=> int(4) ["d"]=> int(1) ["h"]=> int(8) ["i"]=> int(25) ["s"]=> int(23) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(123) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } 4
Output for hhvm-3.18.5 - 3.22.0
object(DateInterval)#3 (0) { } 4