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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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:
228.62 ms | 401 KiB | 296 Q