php - strtotime 'next month' 未按预期运行(即今天)

标签 php date

到目前为止,这只发生在 31 日

echo date('F',strtotime('this month')); //May
echo date('F',strtotime('next month'));//July
echo date('F',strtotime('+1 month'));//July

据我了解,六月是在五月之后。但我猜 php 很懒,从现在起只添加了 31 天,跳过了整整一个月。

无论长度如何,我如何才能安全地获得下个月?最好使用 strttotime

编辑忘了提及,为什么我希望使用 strtotime 是因为我使用搜索框来查找解释用户输入 strtotime 的事件

最佳答案

最可靠的方法可能是:

date('F', mktime(0, 0, 0, date('n') + 1, 1))

关于php - strtotime 'next month' 未按预期运行(即今天),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6182925/

相关文章:

php - 移动优化网站

php - Google Calendar API 始终对事件列表进行分页

iOS App 不同的时区处理不同的日期条目

javascript - 在 Jquery UI Datepicker 中突出显示特定日期

php - 如果未重定向,则重定向页面

php - PostgreSQL 没有出现在 phpconfig() 函数中(在 Windows 上)

javascript - 使用 Moment.js 查找本周日期的特定日期

xml - 如何获取 XSLT 1.0 中的当前日期?

php - Selenium、php、phpUnit、404 错误调用 testComplete() 而不是继续,我该如何停止?

c# - 如何在C#中生成具有月跨度的序列