3v4l.org

run code in 300+ PHP versions simultaneously
<?php $yearMonth = '2017-06'; $startDate = new \DateTime($yearMonth . '-01'); $endDate = clone $startDate; $endDate->modify('last day of this month'); $startDate->modify('monday this week 00:00:00'); $endDate->modify('sunday this week 23:59:59'); var_dump($startDate); var_dump($endDate);

preferences:
28.21 ms | 402 KiB | 5 Q