3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo extends DateTime { public function __construct($time = null) { $tz = new DateTimeZone('UTC'); try { echo "First try\n"; parent::__construct($time, $tz); return; } catch (Exception $e) { echo "Second try\n"; parent::__construct($time.'C', $tz); } } } $date = '12 Sep 2007 15:49:12 UT'; var_dump(new Foo($date));
Output for 5.4.30 - 7.1.0
First try Second try object(Foo)#1 (3) { ["date"]=> string(26) "2007-09-12 15:49:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.4.29
First try Second try NULL
Output for 5.3.0 - 5.4.28
First try Second try object(Foo)#1 (3) { ["date"]=> string(19) "2007-09-12 15:49:12" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
Output for 5.2.0 - 5.2.17
First try Second try object(Foo)#1 (0) { }
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/cGnD2 on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cGnD2 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/cGnD2 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/cGnD2 on line 4
Process exited with code 255.