strtotime“下个月”不按预期行事(今天是) [英] strtotime 'next month' not acting as expected (today that is)

查看:93
本文介绍了strtotime“下个月”不按预期行事(今天是)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这只是在31日才发生

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

据我所知,June于五月之后。但是我猜猜,从现在起31天,php正在懒惰,跳过了一整个月。

As far as I understand June comes after May. But i'm guessing php is being lazy in just adding 31 days from now, skipping an entire month.

如何安全地获得下个月,无论长度如何?理想地使用strttotime

How can I safely get the next month regardless of lenght? Ideally using strttotime

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

edit Forgot to mention, why i was hoping to use strtotime is that I'm using a search box to find events interpreting user input strtotime

推荐答案

最有效的方法可能是:

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

这篇关于strtotime“下个月”不按预期行事(今天是)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆