【问题标题】:'first monday previous month' strtotime confusion'上个月的第一个星期一' strtotime 混乱
【发布时间】:2015-05-14 08:54:17
【问题描述】:

今天是 2015-05-14

为什么

date('Y-m-d', strtotime('first monday previous month'))

返回

string(10) "2015-04-18"

我预计这将在 2015 年 4 月 6 日 - 上个月的第一个星期一返回。

【问题讨论】:

  • 因为上个月是2015-04-14,所以在previous month前加of

标签: php strtotime


【解决方案1】:

datetime 字符串中缺少 of。试试 -

date('Y-m-d', strtotime('first monday of previous month'));

Docs

【讨论】:

    【解决方案2】:

    请试试这个..

    echo date('Y-m-d', strtotime('First Monday of ' . date("Y-m-d", strtotime("-1 months") ) ));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-05
      • 1970-01-01
      • 2014-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多