Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在使用以下代码来计算下个月:
$nextMonth = date("m",strtotime("+1 months"));
如果当前日期是 3 月 31 日 (03),则此代码给我“05”,这实际上距当前日期 2 个月。我希望它改为返回四月 (04)。
我怎样才能做到这一点?
试试这个怎么样:
$d = new DateTime(date("Y-m-d")); $d->modify( 'first day of next month' ); echo $d->format( 'F' ), "\n";
丁斯