【问题标题】:Get month after and before given month name获取给定月份名称之后和之前的月份
【发布时间】:2012-05-09 10:30:51
【问题描述】:

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

我试过了:

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

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

然后我怎么才能得到前一个月?

我试过了

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

【问题讨论】:

    标签: php date strtotime


    【解决方案1】:
    $next_month = date('F',strtotime('June + 1 month'));
    

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

    编辑

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

    【讨论】:

    • 上个月怎么样?
    • echo date('F',strtotime('June ' . date('Y') . ' -1 month')); - 您需要包含上个月的年份。 reference
    【解决方案2】:
    echo date('F',strtotime('June + 1 month'));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      相关资源
      最近更新 更多