Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This is only happening on the 31st so far

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

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.

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
572 views
Welcome To Ask or Share your Answers For Others

1 Answer

The most robust way is probably:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...