3v4l.org

run code in 200+ PHP versions simultaneously
<?php $d = new DateTime("first day of january 2017"); echo "first day of: ", $d->setDate(2015, 12, 31)->format("Y-m-d"); $d = new DateTime("last day of december 2017"); echo "\nlast day of: ", $d->setDate(2016, 1, 1)->format("Y-m-d");
Output for 7.0.17 - 7.0.20, 7.1.3 - 7.4.0
first day of: 2015-12-31 last day of: 2016-01-01
Output for 7.0.0 - 7.0.16, 7.1.0 - 7.1.2
first day of: 2015-12-01 last day of: 2016-01-31