title: Looping dates by month Codeigniter
body: <p>I want to loop start date and end date and generate dates by month. I use this code:</p>
  
  <pre><code>&lt;?php
      $start    = (new DateTime($cust_data-&gt;date_sold));
      $end      = (new DateTime($cust_data-&gt;due_date));
      $interval = DateInterval::createFromDateString('1 month');
      $period   = new DatePeriod($start, $interval, $end);
  
      foreach ($period as $dt) {
         echo "&lt;tr&gt;";
         echo "&lt;td&gt;".$dt-&gt;format("m-d-Y")."&lt;/td&gt;";
         echo "&lt;/tr&gt;";
      }
  </code></pre>
  
  <p>Example date: </p>
  
  <pre><code>$start = '02-05-2018'
  $end = '08-05-2018'
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>02-05-2018
  
  03-05-2018
  
  04-05-2018
  
  05-05-2018
  
  06-05-2018
  
  07-05-2018
  </code></pre>
  
  <p>I want it to be like this:</p>
  
  <pre><code>03-05-2018
  
  04-05-2018
  
  05-05-2018
  
  06-05-2018
  
  07-05-2018
  
  08-05-2018
  </code></pre>
  
  <p>But I don't know how.</p>