3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = new DateTime('2016-11-05'); // saturday var_dump($date->modify('friday this week')); $date2 = new DateTime('2016-11-06'); // sunday var_dump($date2->modify('friday this week'));
based on sHHo0
Output for 7.0.17 - 7.0.20, 7.1.3 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.27, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-11-04 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-11-04 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.23 - 5.6.30, 7.0.8 - 7.0.16, 7.1.0 - 7.1.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-11-04 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-10-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.0 - 5.6.22, 7.0.0 - 7.0.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-11-04 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-11-11 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }