3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $intervals = array( '1 second' => 1, '1 minute' => 60 * 60, '1 day' => 60 * 60 * 24, '1 year' => 60 * 60 * 24 * 365 ); foreach ($intervals as $interval => $expected) { $zeroDate = new \DateTime('@0'); $zeroDate->add(\DateInterval::createFromDateString($interval)); echo (sprintf('found %s expected %s', $zeroDate->getTimestamp(), $expected)); }
Output for 5.3.0 - 5.3.8, 5.4.8 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
found 1 expected 1found 60 expected 3600found 86400 expected 86400found 31536000 expected 31536000
Output for 5.3.9 - 5.4.7
found 3601 expected 1found 3660 expected 3600found 90000 expected 86400found 31539600 expected 31536000
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 11 Fatal error: Call to undefined method DateTime::add() in /in/FgKiO on line 11
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 11 Fatal error: Class 'DateTime' not found in /in/FgKiO on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 11 Fatal error: Cannot instantiate non-existent class: datetime in /in/FgKiO on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FgKiO on line 11 Fatal error: Cannot instantiate non-existent class: datetime in /in/FgKiO on line 10