3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php foreach (range(0,8) as $days) { $a1 = new DateTime('2016-03-07 18:02:40'); $a1->modify("+$days days"); var_dump($a1->modify('next week')); }
based on ZQtPT
Output for 5.6.28, 7.0.20 - 7.3.0rc3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-21 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30 - 5.6.21, 7.0.0 - 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-14 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-21 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-21 18:02:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.23 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-14 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-14 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-14 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-14 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-14 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-14 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-21 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-21 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-21 18:02:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }