echo date('Y-m-d', strtotime('First Monday '.date('F o', strtotime("-4 months")));
Run Code Online (Sandbox Code Playgroud)
以上代码返回2012-10-08,这是不正确的 - 2012年10月的第一个星期一应该返回2012-10-01.
手册中的更改日志(http://php.net/manual/en/function.strtotime.php)指定以下内容:
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.
Run Code Online (Sandbox Code Playgroud)
似乎很清楚,这是导致错误返回日期的原因,但是我使用的是PHP版本5.4.7(在localhost上运行xamp)!
有任何想法吗?
of尝试检索该月的第一天时,您缺少关键字
echo date('Y-m-d', strtotime('First Monday of '.date('F o', strtotime("-4 months")));
Run Code Online (Sandbox Code Playgroud)
我在这个bug报告中找到了相关信息
我目前的版本是PHP 5.4.4,以防它仍然不适合你
| 归档时间: |
|
| 查看次数: |
3746 次 |
| 最近记录: |