3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class DateTimeCustom extends DateTime { public function setDateTime($datetime, $timezone = null) { parent::__construct($datetime, $timezone); var_dump($this->getLastErrors()); } } $date = new DateTimeCustom('now'); $date->setDateTime('2014-10-00');
Output for 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { ["warning_count"]=> int(1) ["warnings"]=> array(1) { [11]=> string(27) "The parsed date was invalid" } ["error_count"]=> int(0) ["errors"]=> array(0) { } }
Output for 5.4.0 - 5.4.45
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /in/8WV9Q:14 Stack trace: #0 /in/8WV9Q(14): DateTime->__construct('now') #1 {main} thrown in /in/8WV9Q on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead' in /in/8WV9Q:14 Stack trace: #0 /in/8WV9Q(14): DateTime->__construct('now') #1 {main} thrown in /in/8WV9Q on line 14
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() expects parameter 2 to be DateTimeZone, null given' in /in/8WV9Q:8 Stack trace: #0 /in/8WV9Q(8): DateTime->__construct('2014-10-00', NULL) #1 /in/8WV9Q(16): DateTimeCustom->setDateTime('2014-10-00') #2 {main} thrown in /in/8WV9Q on line 8
Process exited with code 255.
Output for 5.2.1 - 5.2.2
<br /> <b>Fatal error</b>: Uncaught exception 'Exception' with message 'DateTime::__construct() expects parameter 2 to be DateTimeZone, null given' in /in/8WV9Q:8 Stack trace: #0 /in/8WV9Q(8): DateTime-&gt;__construct('2014-10-00', NULL) #1 /in/8WV9Q(16): DateTimeCustom-&gt;setDateTime('2014-10-00') #2 {main} thrown in <b>/in/8WV9Q</b> on line <b>8</b><br />
Process exited with code 255.
Output for 5.2.0
<br /> <b>Warning</b>: DateTime::__construct() expects parameter 2 to be DateTimeZone, null given in <b>/in/8WV9Q</b> on line <b>8</b><br /> <br /> <b>Fatal error</b>: Call to undefined method DateTimeCustom::getLastErrors() in <b>/in/8WV9Q</b> on line <b>9</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.1.6
<br /> <b>Fatal error</b>: Class 'DateTime' not found in <b>/in/8WV9Q</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/8WV9Q</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/8WV9Q</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/8WV9Q</b> on line <b>6</b><br />
Process exited with code 255.