3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateTime extends \DateTime { public static function createFromFormat($format, $time, $timezone = null) { if (null === $timezone) { $timezone = new DateTimeZone(date_default_timezone_get()); } return new DateTime(parent::createFromFormat($format, $time, $timezone)); } } var_Dump(MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17', new DateTimeZone('Europe/Berlin'))->format('c')); var_Dump(MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17')->format('c'));
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Deprecated: Return type of MyDateTime::createFromFormat($format, $time, $timezone = null) should either be compatible with DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/v5kXX on line 4 string(25) "2020-06-23T13:46:56+02:00" string(25) "2020-06-23T13:46:56+02:00"
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
string(25) "2020-06-23T13:46:56+02:00" string(25) "2020-06-23T13:46:56+02:00"
Output for 7.3.32 - 7.3.33, 8.0.13
string(25) "2020-06-23T11:46:56+00:00" string(25) "2020-06-23T11:46:56+00:00"

preferences:
149.96 ms | 408 KiB | 5 Q