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');
based on H3jZY
Output for 5.6.19 - 5.6.28, 7.0.4 - 7.2.0
2014-01-21
Output for 5.3.18 - 5.6.18, 7.0.0 - 7.0.3
2014-01-31