3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(\DateTime::createFromFormat('Y-m-d', '0000-00-00')); $birthday = date('d-m-Y', strtotime('0000-00-00')); $birthDate = explode('-', $birthday); echo $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y") - $birthDate[2]) - 1) : (date("Y") - $birthDate[2]));
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 18:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Fatal error: Uncaught TypeError: mktime(): Argument #6 ($year) must be of type ?int, string given in /in/QRSd3:8 Stack trace: #0 /in/QRSd3(8): mktime(0, 0, 0, '30', '11', '') #1 {main} thrown in /in/QRSd3 on line 8
Process exited with code 255.
Output for 8.0.13
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 16:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } Fatal error: Uncaught TypeError: mktime(): Argument #6 ($year) must be of type ?int, string given in /in/QRSd3:8 Stack trace: #0 /in/QRSd3(8): mktime(0, 0, 0, '30', '11', '') #1 {main} thrown in /in/QRSd3 on line 8
Process exited with code 255.
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 18:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: mktime() expects parameter 6 to be int, string given in /in/QRSd3 on line 8 Warning: A non-numeric value encountered in /in/QRSd3 on line 10 2015
Output for 7.3.32 - 7.3.33
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 16:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } Warning: mktime() expects parameter 6 to be int, string given in /in/QRSd3 on line 8 Warning: A non-numeric value encountered in /in/QRSd3 on line 10 2015
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 18:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: mktime() expects parameter 6 to be integer, string given in /in/QRSd3 on line 8 Warning: A non-numeric value encountered in /in/QRSd3 on line 10 2015
Output for 7.0.0 - 7.0.20
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 18:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: mktime() expects parameter 6 to be integer, string given in /in/QRSd3 on line 8 2015
Output for 5.4.30 - 5.4.45, 5.5.14 - 5.5.38, 5.6.0 - 5.6.25
object(DateTime)#1 (3) { ["date"]=> string(27) "-0001-11-30 18:33:19.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: mktime() expects parameter 6 to be long, string given in /in/QRSd3 on line 8 2015
Output for 5.4.0 - 5.4.29, 5.5.0 - 5.5.13
object(DateTime)#1 (3) { ["date"]=> string(20) "-0001-11-30 18:33:19" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: mktime() expects parameter 6 to be long, string given in /in/QRSd3 on line 8 2015

preferences:
256.74 ms | 402 KiB | 313 Q