echo date('Y-m-d', strtotime('First Monday '.date('F o', strtotime("-4 months")));
The above code returns 2012-10-08, which is incorrect - the first monday of october 2012 should return 2012-10-01.
The changelog from the manual (http://php.net/manual/en/function.strtotime.php) specifies the following:
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.
It seems to be clear that this is what's causing the wrong return date, however I'm using PHP version 5.4.7 (running xamp on localhost)!
Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…