Cross-year DatePeriod width DateInterval P7D losing new year week <p>I'm trying to have an array of yearweeks using PHP DatePeriod like so :</p> <pre><code>$from = new DateTime('2014-09-16'); $to = new DateTime('2015-02-25'); $interval = new DateInterval('P7D'); // 7Days =&gt; 1 Week $daterange = new DatePeriod($from, $interval, $to); $yearweeks = array(); foreach($daterange as $date) { $yearweeks[$date-&gt;format('YW')] = 'W' . $date-&gt;format('W-Y'); } </code></pre> <p>The result is pretty strange ! The first week of the new year is missing. I have fist week of previous year instead like so :</p> <pre><code>Array ( ... [201451] =&gt; W51-2014 [201452] =&gt; W52-2014 [201401] =&gt; W01-2014 // WTF ? /!\ [201501] =&gt; W01-2015 expected ! /!\ [201502] =&gt; W02-2015 [201503] =&gt; W03-2015 ... ) </code></pre> <p>Is there a trick to avoid this kind of error ? </p>