title: Find the date difference in php
body: <p>I want to know what's the way to find the difference of two date. I get the startDate and endDate from a form. Now I want to find the difference of current date and startDate or endDate.</p>
  
  <pre><code>echo $startDate = $startYear.'-'.$startMonth.'-'.$startDay.'&lt;br&gt;';
  echo $endDate = $endYear.'-'.$endMonth.'-'.$endDay;
  $_SESSION['startDate'] = $startDate;
  $_SESSION['endDate'] = $endDate;
  $_SESSION['team'] = $team;
  header('location:test.php');
  </code></pre>
  
  <p>test.php</p>
  
  <pre><code>date_default_timezone_set('Asia/Kuala_Lumpur');
      echo $startDate = $_SESSION['startDate'];
      $date2=date_create(date('Y/m/d'));
      $diff=date_diff($startDate,$date2);
      echo $diff-&gt;format("%R%a days");
  </code></pre>