Calculating no of years between 2 dates in PHP
<p>I need to get the no of years from 2 dates provided.
The code which I tested is here:</p>

<pre><code>&lt;?php


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');
?&gt;
</code></pre>

<p>The $diff gives a number output. When I return $years, am getting 0.
Where I have went wrong?</p>
