Reputation: 645
That's strange, I don't know if it's a bug, but please, someone try it.
Do that on PHP
echo date("Y-W",strtotime("2014W05 -1 weeks"));
The result will be 2014-04, right? YEAR-WEEKNUMBER. No problem at all. But now, try this:
echo date("Y-W",strtotime("2014W02 -1 weeks"));
Why it's 2013-01, why 2013? What's wrong? It should be 2014-01, right?
What I'm doing wrong? Is it a bug?
My PHP version: 5.4.22
Upvotes: 7
Views: 261
Reputation: 1583
Y is year from the date
o is ISO-8601 year number
So if you do it like
echo date("o-W",strtotime("2014W05 -1 weeks"))."<br/>";
echo date("o-W",strtotime("2014W02 -1 weeks"));
You will get
2014-04
2014-01
Edit By Jasper
Because a date is a moment rather than a week, you request a week and get the first moment of that week. As per the standards, the week number is based on which year the Thursday is in. As such, the week number is 1, but the date is still in 2013.
Upvotes: 10