3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('UTC'); $date = new \DateTime(null, new \DateTimeZone('UTC')); $date->setTime(0,0,0); $date->modify('next month'); $date->modify('last day of this month'); $date->setDate(2014, 1, 21); // This should be 21st Jan 2014 echo $date->format('Y-m-d h:i:s');
based on ZKBVP
Output for 5.6.19 - 5.6.21, 7.0.4 - 7.2.0
2014-01-21 12:00:00
Output for 5.3.18 - 5.6.18, 7.0.0 - 7.0.3
2014-01-31 12:00:00