获取给定月份名称之前和之后的月份

RSM*_*RSM 3 php date strtotime

如何在给定月份后获取月份名称.所以对于六月,我想要七月

我试过了:

$next_month = date('F',strtotime('June', "next month"));
Run Code Online (Sandbox Code Playgroud)

这显示一月,这显然是错误的,我正在寻找七月.

那我怎么能在前一个月得到?

我试过了

$prev_month = date('F',strtotime('June - 1 month'));
Run Code Online (Sandbox Code Playgroud)

Aar*_* W. 11

$next_month = date('F',strtotime('June + 1 month'));
Run Code Online (Sandbox Code Playgroud)

要么

$next_month = date('F',strtotime('June next month'));
Run Code Online (Sandbox Code Playgroud)

编辑

$next_month = date('F',strtotime('June last month'));
Run Code Online (Sandbox Code Playgroud)

  • `echo date('F',strtotime('June ' . date('Y') . ' -1 Month'));` - 您需要包含上个月的年份。[参考](http://stackoverflow.com/q/5489502/138383) (2认同)