3v4l.org

run code in 200+ php & hhvm versions
<?php ini_set("date.timezone", "GMT"); $objDateTo = new dateTime('2017-10-01'); $objDateFrom = new dateTime('2017-01-01'); $interval = $objDateTo->diff($objDateFrom); echo "Date Only: " . $interval->m . "\r\n"; $objDateTo = new dateTime('2017-10-01 12:00:00'); $objDateFrom = new dateTime('2017-01-01 12:00:00'); $interval = $objDateTo->diff($objDateFrom); echo "Date and Time: " . $interval->m;
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.2.6
Date Only: 9 Date and Time: 9