3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php var_dump( new \DateTime('tomorrow') ); var_dump( new \DateTime('-1 week|') ); var_dump( (new \DateTime('2015-03-04'))->format('H:i') ); var_dump( \DateTime::createFromFormat('Y-m-d', '2015-03-04')->format('H:i') ); var_dump( \DateTime::createFromFormat('!Y-m-d', '2015-03-04')->format('H:i') ); var_dump( \DateTime::createFromFormat('|Y-m-d', '2015-03-04')->format('H:i') );
based on nQQHY
Output for 7.0.0 - 7.3.0rc6
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-05 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (-1 week|) at position 7 (|): Unexpected character in /in/0nWtB:8 Stack trace: #0 /in/0nWtB(8): DateTime->__construct('-1 week|') #1 {main} thrown in /in/0nWtB on line 8
Process exited with code 255.
Output for hhvm-3.15.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-05 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (-1 week|) at position 7 (|): Unexpected character' in /in/0nWtB:8 Stack trace: #0 /in/0nWtB(8): DateTime->__construct() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-05 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (-1 week|) at position 7 (|): Unexpected character' in /in/0nWtB:8 Stack trace: #0 /in/0nWtB(8): DateTime->__construct('-1 week|') #1 {main} thrown in /in/0nWtB on line 8
Process exited with code 255.