I think I am fully aware of ISO 8601 and that the first week of the year is the week in which there is Monday. However, I met strange behavior in PHP (5.6) DateTime Class.
Here is my code:
$start = new DateTime('2009-01-01 00:00'); $end = new DateTime(); $point = $start; while($point <= $end){ echo $point->format('YW'); $point = $point->modify('next week'); }
It does the right thing
200901 200902 200903 ...
But if I choose to start something earlier in 2008, for example $start = new DateTime('2008-01-01 00:00'); , then we get a different result:
... 200852 200801
Is this a PHP bug or am I missing something?
source share