3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (function_exists('date_default_timezone_set')) date_default_timezone_set("UTC"); echo "works as expected:\n"; echo date("Y-m-d H:i:s", strtotime("2019W14")) . " should be 2019-04-01\n"; echo date("Y-m-d H:i:s", strtotime("2019W15")) . " should be 2019-04-08\n"; echo date("Y-m-d H:i:s", strtotime("2019W16")) . " should be 2019-04-15\n\n"; echo "off by one:\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next tuesday")) . " should be 2019-04-16\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next wednesday")) . " should be 2019-04-17\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next thursday")) . " should be 2019-04-18\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next friday")) . " should be 2019-04-19\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next saturday")) . " should be 2019-04-20\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next sunday")) . " should be 2019-04-21\n"; echo date("Y-m-d H:i:s", strtotime("2019W16 next monday")) . " should be 2019-04-22\n\n"; echo "works as expected:\n"; echo date("Y-m-d H:i:s", strtotime("2019-04-15 next monday")) . " should be 2019-04-22\n"; echo date("Y-m-d H:i:s", strtotime("2019-04-15 next friday")) . " should be 2019-04-19\n"; echo date("Y-m-d H:i:s", strtotime("2019-04-15 next thursday")) . " should be 2019-04-18\n";
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 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.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
works as expected: 2019-04-01 00:00:00 should be 2019-04-01 2019-04-08 00:00:00 should be 2019-04-08 2019-04-15 00:00:00 should be 2019-04-15 off by one: 2019-04-22 00:00:00 should be 2019-04-16 2019-04-16 00:00:00 should be 2019-04-17 2019-04-17 00:00:00 should be 2019-04-18 2019-04-18 00:00:00 should be 2019-04-19 2019-04-19 00:00:00 should be 2019-04-20 2019-04-20 00:00:00 should be 2019-04-21 2019-04-21 00:00:00 should be 2019-04-22 works as expected: 2019-04-22 00:00:00 should be 2019-04-22 2019-04-19 00:00:00 should be 2019-04-19 2019-04-18 00:00:00 should be 2019-04-18
Output for 5.1.0 - 5.1.6
works as expected: 2019-04-01 00:00:00 should be 2019-04-01 2019-04-08 00:00:00 should be 2019-04-08 2019-04-15 00:00:00 should be 2019-04-15 off by one: 2019-04-16 00:00:00 should be 2019-04-16 2019-04-17 00:00:00 should be 2019-04-17 2019-04-18 00:00:00 should be 2019-04-18 2019-04-19 00:00:00 should be 2019-04-19 2019-04-20 00:00:00 should be 2019-04-20 2019-04-21 00:00:00 should be 2019-04-21 2019-04-22 00:00:00 should be 2019-04-22 works as expected: 2019-04-22 00:00:00 should be 2019-04-22 2019-04-19 00:00:00 should be 2019-04-19 2019-04-18 00:00:00 should be 2019-04-18
Output for 5.0.0 - 5.0.5
works as expected: 2019-01-03 00:00:00 should be 2019-04-01 2019-01-04 00:00:00 should be 2019-04-08 2019-01-05 00:00:00 should be 2019-04-15 off by one: 2019-01-05 00:00:00 should be 2019-04-16 2019-01-05 00:00:00 should be 2019-04-17 2019-01-05 00:00:00 should be 2019-04-18 2019-01-05 00:00:00 should be 2019-04-19 2019-01-05 00:00:00 should be 2019-04-20 2019-01-05 00:00:00 should be 2019-04-21 2019-01-05 00:00:00 should be 2019-04-22 works as expected: 2019-04-15 00:00:00 should be 2019-04-22 2019-04-15 00:00:00 should be 2019-04-19 2019-04-15 00:00:00 should be 2019-04-18
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
works as expected: 1970-01-01 00:59:59 should be 2019-04-01 1970-01-01 00:59:59 should be 2019-04-08 1970-01-01 00:59:59 should be 2019-04-15 off by one: 1970-01-01 00:59:59 should be 2019-04-16 1970-01-01 00:59:59 should be 2019-04-17 1970-01-01 00:59:59 should be 2019-04-18 1970-01-01 00:59:59 should be 2019-04-19 1970-01-01 00:59:59 should be 2019-04-20 1970-01-01 00:59:59 should be 2019-04-21 1970-01-01 00:59:59 should be 2019-04-22 works as expected: 2019-04-15 00:00:00 should be 2019-04-22 2019-04-15 00:00:00 should be 2019-04-19 2019-04-15 00:00:00 should be 2019-04-18

preferences:
325.43 ms | 403 KiB | 452 Q