title: PHP - Count number of days between 2 dates
body: <p>I am trying to write a function that can count the number of days between 2 dates. I currently have the below but it is giving me some unexpected results:</p>
  
  <pre><code>function dayCount($from, $to) {
      $first_date = strtotime($from);
      $second_date = strtotime($to);
      $offset = $second_date-$first_date; 
      return floor($offset/60/60/24);
  }
  
  print dayCount($s, $e).' Days';
  </code></pre>
  
  <p>A couple of correct examples: </p>
  
  <pre><code>$s = '18-03-2016';
  $e = '25-03-2016';
  </code></pre>
  
  <p>Outputs: <code>7 Days</code> - <strong>correct</strong></p>
  
  <pre><code>$s = '03-02-2016';
  $e = '06-02-2016';
  </code></pre>
  
  <p>Outputs: <code>3 Days</code> - <strong>correct</strong></p>
  
  <pre><code>$s = '06-04-2016';
  $e = '27-04-2016';
  </code></pre>
  
  <p>Outputs: <code>21 Days</code> - <strong>correct</strong></p>
  
  <p>But when I have dates that cross over between 2 months sometimes it is correct, sometimes it shows a day less: </p>
  
  <pre><code>$s = '25-03-2016';
  $e = '01-04-2016';
  </code></pre>
  
  <p>Outputs: <code>6 Days</code> - <strong>should be 7 Days</strong></p>
  
  <pre><code>$s = '23-02-2016';
  $e = '01-03-2016';
  </code></pre>
  
  <p>Outputs: <code>7 Days</code> - <strong>correct</strong></p>