title: Get a $date between start and end dates on a continuous loop
body: <p>Trying to figure out a way of achieving the following scenario:-</p>
  
  <p>The user creates an initial time period e.g. 01/01/2013 to 01/07/2013 and a renewal period e.g. every 1 month.</p>
  
  <p>I'm working on a function that will:-</p>
  
  <ol>
  <li>Detect whether the date passed in a function (could be any date) falls a period matching the users requirements.</li>
  </ol>
  
  <p>For example:-</p>
  
  <p>The function may accept the following date 21/02/2019. Based on this I need to detect which renewal period the user is in.</p>
  
  <p>The way I was thinking of achieving this is by:-</p>
  
  <ol>
  <li>Add one day to the users initial start date to get the newest renewal date.</li>
  <li>Add the renewal period (1 month) to this to get the newest end date.</li>
  <li>Keep doing this until I detect which start and end dates the date falls between based on the users renewal period type e.g. 1 month.</li>
  </ol>
  
  <p>A bit confusing but this kind of sums up what I'm after but isn't working:-</p>
  
  <pre><code>$tmpStartDate=$endDate;   
  do{
  $tmpStartDate=date("Ymd",strtotime($tmpStartDate .'+1 Day'));
  $tmpEndDate=date("Ymd",strtotime($tmpStartDate .'+'.$timingUnitVal .' '.$timingUnit));
  } while($date&lt;$tmpStartDate&amp;&amp;$date&gt;$tmpEndDate);
  </code></pre>
  
  <p>$endDate is the end date initially entered by the user.</p>