- mktime: documentation ( source)
- date: documentation ( source)
- min: documentation ( source)
<?php
$date = mktime(0, 0, 0, 1, 31); // midnight Jan 31st
$oneMonthLater = mktime(0, 0, 0,
date('n', $date) + 1,
min(date('t', $date), date('j', $date)),
date('Y', $date));
echo date('Y-m-d h:i:s', $oneMonthLater);