Unexpected result using DatePeriod with DateTime::add()
<p>I expect the following code to generate a list of 5 consecutive days starting with today.</p>

<pre><code>$startDay = new DateTime();
for($i = 0; $i &lt;=4; $i++){
    $courseDay = $startDay-&gt;add(new DateInterval("P{$i}D"));
    print_r($courseDay-&gt;format('j-M-Y') . "\n");
}
</code></pre>

<p>However it gives the following output when run today (21st October 2011):-</p>

<pre><code>21-Oct-2011
22-Oct-2011
24-Oct-2011
27-Oct-2011
31-Oct-2011
</code></pre>

<p>I don't see anything wrong with the code, can anybody else? Why is it jumping days?</p>

<p><strong>Update</strong><br>
I worked out the answer to this while typing this question, so will post my own answer.</p>
