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 = 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/pMrhY on line 4 string(25) "2017-01-17T16:06:46+01:00" Fatal error: Uncaught TypeError: DateTime::createFromFormat(): Argument #3 ($timezone) must be of type ?DateTimeZone, string given in /in/pMrhY:8 Stack trace: #0 /in/pMrhY(8): DateTime::createFromFormat('yy-mm-dd', '2017-01-17', 'Europe/Amsterda...') #1 /in/pMrhY(13): MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17') #2 {main} thrown in /in/pMrhY on line 8
Process exited with code 255.
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/pMrhY on line 4 string(25) "2017-01-17T16:06:46+01:00" Fatal error: Uncaught TypeError: DateTime::createFromFormat(): Argument #3 ($timezone) must be of type ?DateTimeZone, string given in /in/pMrhY:8 Stack trace: #0 /in/pMrhY(8): DateTime::createFromFormat('yy-mm-dd', '2017-01-17', 'Europe/Amsterda...') #1 /in/pMrhY(13): MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17') #2 {main} thrown in /in/pMrhY on line 8
Process exited with code 255.
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
string(25) "2017-01-17T16:06:46+01:00" Fatal error: Uncaught TypeError: DateTime::createFromFormat(): Argument #3 ($timezone) must be of type ?DateTimeZone, string given in /in/pMrhY:8 Stack trace: #0 /in/pMrhY(8): DateTime::createFromFormat('yy-mm-dd', '2017-01-17', 'Europe/Amsterda...') #1 /in/pMrhY(13): MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17') #2 {main} thrown in /in/pMrhY on line 8
Process exited with code 255.
Output for 8.0.13
string(25) "2017-01-17T15:06:46+00:00" Fatal error: Uncaught TypeError: DateTime::createFromFormat(): Argument #3 ($timezone) must be of type ?DateTimeZone, string given in /in/pMrhY:8 Stack trace: #0 /in/pMrhY(8): DateTime::createFromFormat('yy-mm-dd', '2017-01-17', 'UTC') #1 /in/pMrhY(13): MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17') #2 {main} thrown in /in/pMrhY on line 8
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
string(25) "2017-01-17T16:06:46+01:00" Fatal error: Uncaught TypeError: Argument 3 passed to DateTime::createFromFormat() must be an instance of DateTimeZone or null, string given in /in/pMrhY:8 Stack trace: #0 /in/pMrhY(8): DateTime::createFromFormat('yy-mm-dd', '2017-01-17', 'Europe/Amsterda...') #1 /in/pMrhY(13): MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17') #2 {main} thrown in /in/pMrhY on line 8
Process exited with code 255.
Output for 7.3.32 - 7.3.33
string(25) "2017-01-17T15:06:46+00:00" Fatal error: Uncaught TypeError: Argument 3 passed to DateTime::createFromFormat() must be an instance of DateTimeZone or null, string given in /in/pMrhY:8 Stack trace: #0 /in/pMrhY(8): DateTime::createFromFormat('yy-mm-dd', '2017-01-17', 'UTC') #1 /in/pMrhY(13): MyDateTime::createFromFormat('yy-mm-dd', '2017-01-17') #2 {main} thrown in /in/pMrhY on line 8
Process exited with code 255.
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.13, 7.0.20, 7.1.0 - 7.1.20
string(25) "2017-01-17T16:06:46+01:00" Warning: DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, string given in /in/pMrhY on line 8 string(25) "2017-01-17T16:06:46+01:00"
Output for 5.6.29, 7.0.14
string(25) "2017-01-17T16:06:45+01:00" Warning: DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, string given in /in/pMrhY on line 8 string(25) "2017-01-17T16:06:45+01:00"

preferences:
165.29 ms | 401 KiB | 194 Q