hi, i need to calculate the age from mysql date format.
I found a way to do that but its not accurate. e.g dob is 1st may 1987 and it calculate it as 21yrs old. it shu be 20+ as the acutal month of birthday is not over.
here is my code:
function datediff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $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]);
return $end_date - $start_date;
}
$dob='1987-05-01';
round(datediff("-", date("Y-m-d", time()), $dob)/365, 0)
any idea guys??