This is a very simple script that starts from a string date in format yyyy-mm-dd and return the age.
To do this it splits the date, calculate years with difference from current year and the fix the value based on difference between months and days from current date:
// input $date string format: YYYY-MM-DD
function age($date){
list($year,$month,$day) = explode("-",$date);
$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;
}
Related posts:

September 20th, 2010 1:18 pm
Easier Way to do this:
http://www.sudhirhub.com/2010/09/get-age-from-birthdate-using-php.html
December 25th, 2010 11:58 am
age(“1994-04-27″);
I’m 16, but this function shows only 15 :D
January 10th, 2011 8:58 am
Really? :D it needs a fix.