3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date = mktime(0, 0, 0, 1, 31); // midnight Jan 31st $nextMonth = mktime(0, 0, 0, date('n', $date) + 1, 1, date('Y', $date)); $newDate = mktime(0, 0, 0, date('n', $nextMonth), min(date('t', $nextMonth), date('j', $date)), date('Y', $nextMonth)); echo date('Y-m-d H:i:s', $newDate);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2013-02-28 00:00:00