3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo "Using US/Pacific:\n"; date_default_timezone_set('US/Pacific'); $dateJan = new \DateTime('2018-01-30'); $dateMar = new \DateTime('2018-03-01'); echo "\ndateJan:" . $dateJan->format('r')."\n"; echo "\ndateMar:" . $dateMar->format('r')."\n"; echo "\nDiff Jan to Mar\n"; echo 'Diff Months: ' . (clone $dateMar)->diff((clone $dateJan))->m."\n"; echo 'Diff Days: ' . (clone $dateMar)->diff((clone $dateJan))->d."\n"; echo 'Diff Days abs: ' . (clone $dateMar)->diff((clone $dateJan))->days."\n"; echo 'Diff Hours: ' . (clone $dateMar)->diff((clone $dateJan))->h."\n"; echo "\nDiff Mar to Jan\n"; echo 'Diff Months: ' . (clone $dateJan)->diff((clone $dateMar))->m."\n"; echo 'Diff Days: ' . (clone $dateJan)->diff((clone $dateMar))->d."\n"; echo 'Diff Days abs: ' . (clone $dateJan)->diff((clone $dateMar))->days."\n"; echo 'Diff Hours: ' . (clone $dateJan)->diff((clone $dateMar))->h."\n"; echo "\nUsing Europe/Amsterdam:\n"; date_default_timezone_set('Europe/Amsterdam'); $dateJan = new \DateTime('2018-01-30'); $dateMar = new \DateTime('2018-03-01'); echo "\ndateJan:" . $dateJan->format('r')."\n"; echo "\ndateMar:" . $dateMar->format('r')."\n"; echo "\nDiff Jan to Mar\n"; echo 'Diff Months: ' . (clone $dateMar)->diff((clone $dateJan))->m."\n"; echo 'Diff Days: ' . (clone $dateMar)->diff((clone $dateJan))->d."\n"; echo 'Diff Days abs: ' . (clone $dateMar)->diff((clone $dateJan))->days."\n"; echo 'Diff Hours: ' . (clone $dateMar)->diff((clone $dateJan))->h."\n"; echo "\nDiff Mar to Jan\n"; echo 'Diff Months: ' . (clone $dateJan)->diff((clone $dateMar))->m."\n"; echo 'Diff Days: ' . (clone $dateJan)->diff((clone $dateMar))->d."\n"; echo 'Diff Days abs: ' . (clone $dateJan)->diff((clone $dateMar))->days."\n"; echo 'Diff Hours: ' . (clone $dateJan)->diff((clone $dateMar))->h."\n";
based on Mc2Cb
Output for hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.2.8
Using US/Pacific: dateJan:Tue, 30 Jan 2018 00:00:00 -0800 dateMar:Thu, 01 Mar 2018 00:00:00 -0800 Diff Jan to Mar Diff Months: 1 Diff Days: 2 Diff Days abs: 30 Diff Hours: 0 Diff Mar to Jan Diff Months: 0 Diff Days: 30 Diff Days abs: 30 Diff Hours: 0 Using Europe/Amsterdam: dateJan:Tue, 30 Jan 2018 00:00:00 +0100 dateMar:Thu, 01 Mar 2018 00:00:00 +0100 Diff Jan to Mar Diff Months: 0 Diff Days: 30 Diff Days abs: 30 Diff Hours: 0 Diff Mar to Jan Diff Months: 0 Diff Days: 30 Diff Days abs: 30 Diff Hours: 0
Output for 5.6.30
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in /in/49mag on line 12
Process exited with code 255.