title: Calculating number of years between 2 dates in PHP
body: <p>I need to get the number of years from 2 dates provided. Here's my code:</p>
  
  <pre><code>function daysDifference($endDate, $beginDate)
  {
     $date_parts1=explode("-", $beginDate);
     $date_parts2=explode("-", $endDate);
  
     $start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
     $end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
     $diff = $end_date - $start_date;
     echo $diff;
     $years = floor($diff / (365.25*60*60*24));
     return $years;
  }
  
  echo daysDifference('2011-03-12','2008-03-09');
  </code></pre>
  
  <p>The <code>$diff</code> gives a number output. When I return <code>$years</code>, am getting <code>0</code>. What have I done wrong?</p>