I have this code to show a users age on there profile, The problem is it shows the correct age for some users and the wrong age for others.
Example birthdate 1983-04-21 should show age 24 but instead returns age 23
//calculate years of age (input string: YYYY-MM-DD)
function birthday ($birthday){
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($day_diff < 0 || $month_diff < 0)
$year_diff--;
return $year_diff;
}