This question already has answers here:
strtotime 'next month' not acting as expected (today that is)
(3 个回答)
8年前关闭。
今天是 5 月 31 日
我究竟做错了什么?我不明白为什么下个月给
(3 个回答)
8年前关闭。
今天是 5 月 31 日
$currentM = date('m');
// 05
$nextM = date('m', strtotime('+1 month'));
// 07
我究竟做错了什么?我不明白为什么下个月给
07
。 最佳答案
从今天(31/5)开始的下个月是不存在的31/6,因此它转发到1/7。
您可能希望增加实际月份:$nextM = date('m') % 12 + 1
关于php - 下个月在 PHP 中出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16855023/
10-12 13:59