3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $d1 = new \Datetime('2017-5-1'); $d2 = new \Datetime('2017-6-1'); $d3 = new \Datetime('2017-7-1'); $diff1 = $d1->diff($d2); $diff2 = $d2->diff($d3); echo $diff1->m . " months " . $diff1->d . " days\n"; echo $diff2->m . " months " . $diff2->d . " days\n";
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
1 months 1 days 0 months 30 days