3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(date_default_timezone_get()); // Note: The unix timestamp used is the time this entry was created, not 2016-12-18 var_dump((new \DateTime("2016-12-18"))->format('c')); var_dump((new \DateTime("12/18/2016"))->format('c')); var_dump((new \DateTime("@1479664889"))->format('c')); var_dump((DateTime::createFromFormat("Y-m-d", "2016-12-18"))->format('c')); var_dump((DateTime::createFromFormat("m/d/Y", "12/18/2016"))->format('c')); var_dump((DateTime::createFromFormat("U", "1479664889"))->format('c')); print "---\n"; $lastExample = DateTime::createFromFormat("d/m/Y", "12/18/2016"); var_dump($lastExample->format('c')); var_dump(DateTime::getLastErrors()); $lastExample->setTimeZone(new \DateTimeZone("America/New_York")); var_dump($lastExample->format('c'));
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
string(16) "Europe/Amsterdam" string(25) "2016-12-18T00:00:00+01:00" string(25) "2016-12-18T00:00:00+01:00" string(25) "2016-11-20T18:01:29+00:00" string(25) "2016-12-18T19:12:50+01:00" string(25) "2016-12-18T19:12:50+01:00" string(25) "2016-11-20T18:01:29+00:00" --- string(25) "2017-06-12T19:12:50+02:00" array(4) { ["warning_count"]=> int(1) ["warnings"]=> array(1) { [10]=> string(27) "The parsed date was invalid" } ["error_count"]=> int(0) ["errors"]=> array(0) { } } string(25) "2017-06-12T13:12:50-04:00"
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.3.32 - 7.3.33, 8.0.13
string(3) "UTC" string(25) "2016-12-18T00:00:00+00:00" string(25) "2016-12-18T00:00:00+00:00" string(25) "2016-11-20T18:01:29+00:00" string(25) "2016-12-18T18:12:50+00:00" string(25) "2016-12-18T18:12:50+00:00" string(25) "2016-11-20T18:01:29+00:00" --- string(25) "2017-06-12T18:12:50+00:00" array(4) { ["warning_count"]=> int(1) ["warnings"]=> array(1) { [10]=> string(27) "The parsed date was invalid" } ["error_count"]=> int(0) ["errors"]=> array(0) { } } string(25) "2017-06-12T14:12:50-04:00"
Output for 5.6.0 - 5.6.28
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/6bNlG on line 9
Process exited with code 255.

preferences:
165.77 ms | 411 KiB | 5 Q