PHP age calculator / Alter berechnen

<?php
/**
 * age_calculator()
 *
 * @param int $day DD
 * @param int $month MM
 * @param int $year YYYY
 * @return int $age years
 */
function age_calculator($day,$month,$year){
	if(date("n") > $month){
		$age = (date("Y") - $year);
	}
	elseif(date("n") == $month){
 		if(date("j") < $day){
			$age = (date("Y") - $year) - 1;
		}
 		else
		{
		 	$age = (date("Y") - $year);
		}
 	}
	else
	{
		$age = (date("Y") - $year) - 1;
	}

	return $age;
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *