3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string = '2017-11-29T15:10:24.123+01:00'; $format = \DateTime::RFC3339_EXTENDED; // 'Y-m-d\TH:i:s.vP' $date = new \DateTime($string); $parsed = \DateTime::createFromFormat( $date->format($format), $format ); var_dump($string); var_dump($date->format($format)); echo "\n"; var_dump($date); var_dump($parsed); echo "\n"; echo "\n"; var_dump(\DateTime::getLastErrors());
based on UZUpf
Output for 7.0.0 - 7.3.1
string(29) "2017-11-29T15:10:24.123+01:00" string(29) "2017-11-29T15:10:24.123+01:00" object(DateTime)#1 (3) { ["date"]=> string(26) "2017-11-29 15:10:24.123000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+01:00" } bool(false) array(4) { ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(12) ["errors"]=> array(10) { [0]=> string(35) "The format separator does not match" [1]=> string(35) "The format separator does not match" [2]=> string(35) "The format separator does not match" [3]=> string(35) "The format separator does not match" [4]=> string(35) "The format separator does not match" [5]=> string(35) "The format separator does not match" [6]=> string(35) "The format separator does not match" [7]=> string(35) "The format separator does not match" [8]=> string(47) "The timezone could not be found in the database" [15]=> string(12) "Data missing" } }
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Couldn't find constant DateTime::RFC3339_EXTENDED in /in/TK1oK:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.11.1 - 3.21.3
Fatal error: Uncaught Error: Couldn't find constant DateTime::RFC3339_EXTENDED in /in/TK1oK:4 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Fatal error: Couldn't find constant DateTime::RFC3339_EXTENDED in /in/TK1oK on line 4
Process exited with code 255.
Output for 5.3.0 - 5.6.30
Fatal error: Undefined class constant 'RFC3339_EXTENDED' in /in/TK1oK on line 4
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 20 Fatal error: Undefined class constant 'RFC3339_EXTENDED' in /in/TK1oK on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 20 Fatal error: Class 'DateTime' not found in /in/TK1oK on line 4
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 4 Parse error: syntax error, unexpected ';', expecting '(' in /in/TK1oK on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 4 Parse error: parse error, unexpected ';', expecting '(' in /in/TK1oK on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TK1oK on line 4 Parse error: parse error, expecting `'('' in /in/TK1oK on line 4
Process exited with code 255.