Get month after and before given month name

筅森魡賤 提交于 2020-01-04 04:46:07

问题


How do I get the month name after a given month. So for June, I would want July

I have tried:

$next_month = date('F',strtotime('June', "next month"));

This display January, which is obviously wrong, I am looking for July.

How would I then get the month before?

I have tried

$prev_month = date('F',strtotime('June - 1 month'));

回答1:


$next_month = date('F',strtotime('June + 1 month'));

or

$next_month = date('F',strtotime('June next month'));

edit

$next_month = date('F',strtotime('June last month'));



回答2:


echo date('F',strtotime('June + 1 month'));


来源:https://stackoverflow.com/questions/10514291/get-month-after-and-before-given-month-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!