3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = new \DateTime('2018-10-31'); echo $date->format('Y-m-d'), PHP_EOL; for ($i = 0; $i < 6; ++$i) { $date->modify('last day of next month'); echo $date->format('Y-m-d'), PHP_EOL; }
based on rcbeN
Output for 5.6.38 - 7.3.0rc3
2018-10-31 2018-11-30 2018-12-31 2019-01-31 2019-02-28 2019-03-31 2019-04-30