3v4l.org

run code in 300+ PHP versions simultaneously
<?php $monday = new DateTime('this week monday'); $sunday = new DateTime('this week sunday'); $monday->setTime(0, 0, 0); $sunday->setTime(23, 59, 59); $nextMonday = clone $monday; $nextMonday->modify('+1 week'); $nextSunday = clone $sunday; $nextSunday->modify('+1 week'); var_dump( array('monday' => $monday->format('Y-m-d H:i:s'), 'sunday' => $sunday->format('Y-m-d H:i:s'), 'monday' => $nextMonday->format('Y-m-d H:i:s'), 'sunday' => $nextSunday->format('Y-m-d H:i:s')) );
Output for 5.4.8 - 5.4.45, 5.6.28, 7.0.20, 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.4, 8.3.6
array(2) { ["monday"]=> string(19) "2015-09-21 00:00:00" ["sunday"]=> string(19) "2015-09-27 23:59:59" }
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 array(2) { ["monday"]=> string(19) "2015-09-21 00:00:00" ["sunday"]=> string(19) "2015-09-27 23:59:59" }
Output for 5.6.21, 7.0.6
array(2) { ["monday"]=> string(19) "2016-05-09 00:00:00" ["sunday"]=> string(19) "2016-05-15 23:59:59" }
Output for 5.5.30, 5.6.14 - 5.6.16, 7.0.5
array(2) { ["monday"]=> string(19) "2016-04-04 00:00:00" ["sunday"]=> string(19) "2016-04-10 23:59:59" }
Output for 5.5.33, 5.6.19, 7.0.4
array(2) { ["monday"]=> string(19) "2016-03-14 00:00:00" ["sunday"]=> string(19) "2016-03-20 23:59:59" }
Output for 5.5.32, 5.6.17 - 5.6.18, 7.0.3
array(2) { ["monday"]=> string(19) "2016-03-21 00:00:00" ["sunday"]=> string(19) "2016-03-27 23:59:59" }
Output for 5.5.31, 7.0.0 - 7.0.2
array(2) { ["monday"]=> string(19) "2016-03-28 00:00:00" ["sunday"]=> string(19) "2016-04-03 23:59:59" }
Output for 5.6.20
array(2) { ["monday"]=> string(19) "2016-04-11 00:00:00" ["sunday"]=> string(19) "2016-04-17 23:59:59" }
Output for 5.5.29, 5.5.34, 5.6.13
array(2) { ["monday"]=> string(19) "2016-04-18 00:00:00" ["sunday"]=> string(19) "2016-04-24 23:59:59" }
Output for 5.5.27 - 5.5.28, 5.6.11 - 5.6.12
array(2) { ["monday"]=> string(19) "2016-04-25 00:00:00" ["sunday"]=> string(19) "2016-05-01 23:59:59" }
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.10
array(2) { ["monday"]=> string(19) "2016-05-02 00:00:00" ["sunday"]=> string(19) "2016-05-08 23:59:59" }
Output for 5.5.24, 5.5.35, 5.6.7
array(2) { ["monday"]=> string(19) "2016-05-30 00:00:00" ["sunday"]=> string(19) "2016-06-05 23:59:59" }
Output for 5.4.2 - 5.4.7
array(2) { ["monday"]=> string(19) "2015-11-02 00:00:00" ["sunday"]=> string(19) "2015-11-08 23:59:59" }

preferences:
206.61 ms | 401 KiB | 273 Q