title: Why PHP is returning wrong days between two dates?
body: <p>There are a ton of such questions on Stackoverflow and before you mark this as duplicate, let me tell you that none of those work in my case.</p>
  
  <p><a href="https://stackoverflow.com/questions/1940338/date-difference-in-php-on-days">Date Difference in php on days?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1074290/calculate-the-difference-between-date-times-in-php">Calculate the difference between date/times in PHP</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1803003/dates-difference-with-php">Dates difference with php</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2040560/finding-the-number-of-days-between-two-dates">Finding the number of days between two dates</a></p>
  
  <p><a href="https://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates-using-php">How to calculate the difference between two dates using PHP?</a></p>
  
  <p>Above are the questions I have checked. The last question has an answer by <code>Jurka</code> which also unfortunately doesn't works. So here is my code:</p>
  
  <pre><code>$date1 = new DateTime(date('d-m-y'));
  $date2 = new DateTime($etaDate);
  $interval = $date1-&gt;diff($date2);
  echo "difference " . $interval-&gt;days . " days ";
  </code></pre>
  
  <p>The <code>$etaDate</code> in above case is 03-02-16 and the current date is 08-02-16 so it should return 5 days but it returns a very high figure - 1826 days. I have tried different methods which also returns the same day figure.</p>
  
  <p>A date value is stored as string in database so on retrieving I am again putting it back to date format using this code:</p>
  
  <pre><code>$newdate = DateTime::createFromFormat('d-m-y', $EntryDate);
  $newdate-&gt;add(new DateInterval('P15D'));
  $etaDate = $newdate-&gt;format('d-m-y');
  </code></pre>
  
  <p><code>$EntryDate</code> is a variable that holds the date from the database, <code>$etaDate</code> converts it into date format.</p>