I need to get the number of years from 2 dates provided. Here\'s my code:
function daysDifference($endDate, $beginDate)
{
$date_parts1=explode(\"-\", $beg
the $start_date and $end_date' value is the number of days, not seconds. so you should not divide the $diff with 365.25*60*60*24.
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 = abs($end_date - $start_date);
$years = floor($diff / 365.25);
return $years;
}
echo daysDifference('2011-03-12','2008-03-09');