3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startOfWeek = '10-07-2017'; $endOfWeek = new DateTime($startOfWeek); echo $endOfWeek->format('d-m-Y') . "\n"; $endOfWeek->modify('+5 day'); echo $endOfWeek->format('d-m-Y') . "\n"; $endOfWeekString = $endOfWeek->format('d-m-Y'); function firstDayOfWeek($date) { $day = DateTime::createFromFormat('d-m-Y', $date); $day->setISODate((int)$day->format('o'), (int)$day->format('W'), 1); return $day->format('d-m-Y'); } var_dump(firstDayOfWeek($startOfWeek)); echo $endOfWeekString;

preferences:
38.73 ms | 402 KiB | 5 Q