3v4l.org

run code in 300+ PHP versions simultaneously
<?php $first = clone $last = new \DateTime(date('d-m-Y',time())); //this being todays date 21-03-2017 $first->modify('first day of this month'); var_dump($first); $last->modify('last day of this month'); var_dump($last);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12
object(DateTime)#2 (3) { ["date"]=> string(26) "2017-03-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2017-03-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }

preferences:
72.82 ms | 403 KiB | 78 Q