3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $intervals = array( '0' => 0, '86400' => 86400, '0 second' => 0, '1 second' => 1, '1 minute' => 60, '1 hour' => 60 * 60, '1 day' => 60 * 60 * 24, '1 year' => 60 * 60 * 24 * 365, '1 day + 12 hours' => 60 * 60 * 24 + 12 * 60 * 60 ); foreach ($intervals as $interval => $expected) { if (is_numeric($interval)) { $found = (int) $interval; } else { $zeroDate = new \DateTime('0'); $zeroDate->add(\DateInterval::createFromDateString($interval)); $found = $zeroDate->getTimestamp(); } echo sprintf("found %s expected %s\n", $found, $expected); }
Output for 7.0.0 - 7.1.0
found 0 expected 0 found 86400 expected 86400 Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character in /in/qL7bM:18 Stack trace: #0 /in/qL7bM(18): DateTime->__construct('0') #1 {main} thrown in /in/qL7bM on line 18
Process exited with code 255.
Output for 5.3.0 - 5.6.28
found 0 expected 0 found 86400 expected 86400 Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character' in /in/qL7bM:18 Stack trace: #0 /in/qL7bM(18): DateTime->__construct('0') #1 {main} thrown in /in/qL7bM on line 18
Process exited with code 255.
Output for 5.2.4 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 19 found 0 expected 0 found 86400 expected 86400 Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character' in /in/qL7bM:18 Stack trace: #0 /in/qL7bM(18): DateTime->__construct('0') #1 {main} thrown in /in/qL7bM on line 18
Process exited with code 255.
Output for 5.2.0 - 5.2.3
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 19 found 0 expected 0 found 86400 expected 86400 Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (0) at position 0 (' in /in/qL7bM:18 Stack trace: #0 /in/qL7bM(18): DateTime->__construct('0') #1 {main} thrown in /in/qL7bM on line 18
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 19 found 0 expected 0 found 86400 expected 86400 Fatal error: Class 'DateTime' not found in /in/qL7bM on line 18
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 19 found 0 expected 0 found 86400 expected 86400 Fatal error: Cannot instantiate non-existent class: datetime in /in/qL7bM on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/qL7bM on line 19 found 0 expected 0 found 86400 expected 86400 Fatal error: Cannot instantiate non-existent class: datetime in /in/qL7bM on line 18