3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = new DateTime('2017-06-28'); var_dump($date->format('Y-m-d')); $test = floor(1 / 3); var_dump($test); $date->setDate($date->format('Y'), floor(($date->format('m')-1) / 3) * 3 + 1, 1); var_dump($date->format('Y-m-d')); $date = clone($date); $date->modify('+3 month -1 day'); var_dump($date->format('Y-m-d')); $date->setDate($date->format('Y'), 1, 1); var_dump($date->format('Y-m-d')); $date->setDate($date->format('Y'), 12, 31); var_dump($date->format('Y-m-d'));
based on BhrL9
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
string(10) "2017-06-28" float(0) string(10) "2017-04-01" string(10) "2017-06-30" string(10) "2017-01-01" string(10) "2017-12-31"