Php strtotime(';第一个星期一…';)在';s月的第一天返回了错误的日期

Php strtotime(';第一个星期一…';)在';s月的第一天返回了错误的日期,php,Php,上述代码返回2012-10-08,这是不正确的-2012年10月的第一个星期一应返回2012-10-01 手册()中的变更日志指定了以下内容: echo date('Y-m-d', strtotime('First Monday '.date('F o', strtotime("-4 months"))); 很明显,这是导致返回日期错误的原因,但是我使用的是PHP版本5.4.7(在本地主机上运行xamp) 有什么想法吗?在尝试检索月份的第一天时,您缺少了的关键字 In PHP 5 prior

上述代码返回2012-10-08,这是不正确的-2012年10月的第一个星期一应返回2012-10-01

手册()中的变更日志指定了以下内容:

 echo date('Y-m-d', strtotime('First Monday '.date('F o', strtotime("-4 months")));
很明显,这是导致返回日期错误的原因,但是我使用的是PHP版本5.4.7(在本地主机上运行xamp)


有什么想法吗?

在尝试检索月份的第一天时,您缺少了的关键字

In PHP 5 prior to 5.2.7, requesting a given occurrence of a given weekday in a 
month where that weekday was the first day of the month would incorrectly add
one week to the returned timestamp.

This has been corrected in 5.2.7 and later versions.
我找到了关于这个的信息

我当前的版本是PHP5.4.4,以防它仍然不适用于您

PS!“2012年10月的第一个星期一”格式在5.2.7版之前的PHP上不起作用。因此,如果您收到包含1970年的任何返回日期。您需要在strotime()函数中省略“of”。请记住,“First”在5.2.7之前的PHP版本上无法正常工作,
echo date('Y-m-d', strtotime('First Monday of '.date('F o', strtotime("-4 months")));