3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $yearMonth = '2017-06'; $firstDayOfThisMonth = new \DateTime($yearMonth . '-01'); var_dump($firstDayOfThisMonth->format('W')); $lastDayOfThisMonth = clone $firstDayOfThisMonth; $lastDayOfThisMonth = $lastDayOfThisMonth->modify('last day of this month'); var_dump($lastDayOfThisMonth->format('W')); $startDate = new \DateTime($firstDayOfThisMonth->format('Y') . 'W' . $firstDayOfThisMonth->format('W')); $endDate = new \DateTime($lastDayOfThisMonth->format('Y') . 'W' . $lastDayOfThisMonth->format('W')); $endDate->modify('+6 days 23:59:59'); var_dump($startDate); var_dump($endDate); $startDate = new \DateTime($yearMonth . '-01'); $endDate = clone $startDate; $endDate->modify('last day of this month') $startDate->modify('monday this week'); $endDate->modify('sunday this week'); var_dump($startDate); var_dump($endDate);
based on 4YdJg
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.7
Parse error: syntax error, unexpected '$startDate' (T_VARIABLE) in /in/qXF4G on line 27
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_VARIABLE in /in/qXF4G:27 Stack trace: #0 {main}
Process exited with code 255.