Incrementing dates with Carbon
<p>I'm trying to create an array of blackout dates for a reservation system in Laravel 4.  There is one test row in my db with a start_date of 2016-01-24 and end_date of 2016-01-29.</p>

<p>This is the code that pulls the row and loops through the dates using Carbon to increment by one day &amp; add it to an array:</p>

<pre><code>$reserved = Reservation::where('property_id', $property-&gt;id)-&gt;get();

$blackoutDays = [];

foreach($reserved as $r)
{
    $start = new \Carbon\Carbon($r-&gt;start_date);
    $end = new \Carbon\Carbon($r-&gt;end_date);
    $days = $start-&gt;diff($end)-&gt;days;

    for($i = 0; $i &lt;= $days; $i++)
    {
        $date = '';
        $date = $start-&gt;addDays($i);

        $blackoutDays[] = $date-&gt;format('Y-m-j');
    }
}
</code></pre>

<p>What I'm trying to get in $blackoutDays is:</p>

<blockquote>
  <p>["2016-01-24", "2016-01-25", "2016-01-26", "2016-01-27", "2016-01-28", "2016-01-29"]</p>
</blockquote>

<p>But what I'm actually getting is this:</p>

<blockquote>
  <p>["2016-01-24", "2016-01-25", "2016-01-27", "2016-01-30", "2016-02-3", "2016-02-8"]</p>
</blockquote>

<p>Does anyone know why this is happening / how to fix it?  Is there a better way of doing this?</p>