Return to Snippet

Revision: 23612
at February 10, 2010 05:01 by ginoplusio


Initial Code
// 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;
}

Initial URL
http://www.barattalo.it/2010/02/10/php-how-to-calculate-age-from-date-of-birth/

Initial Description


Initial Title
PHP how to calculate age from date of birth

Initial Tags
date

Initial Language
PHP