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

时间:2012-05-09 10:30:52

标签: php date strtotime

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

我试过了:

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

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

我怎么能在前一个月获得?

我试过了

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

2 个答案:

答案 0 :(得分:11)

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

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

修改

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

答案 1 :(得分:1)

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