3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tz = new DateTimeZone('Europe/Amsterdam'); $now = new DateTime('2015-10-01', $tz); $then = new DateTime('2015-01-01', $tz); $diff = $now->diff($then); print_r($diff); $now = new DateTime('2015-09-01', $tz); $then = new DateTime('2015-01-01', $tz); $diff = $now->diff($then); print_r($diff); $now = new DateTime('2015-11-01', $tz); $then = new DateTime('2015-01-01', $tz); $diff = $now->diff($then); print_r($diff);

preferences:
38.49 ms | 402 KiB | 5 Q