Dev Language/PHP
PHP 만나이 계산하기
타카스 류지
2016. 3. 16. 16:18
function getManNai($birth_year,$birth_month,$brith_day){
$birth_year = (int)$birth_year;
$birth_month = (int)$birth_month;
$brith_day = (int)$brith_day;
$now_year = date("Y");
$now_month = date("m");
$now_day = date("d");
if($birth_month < $now_month){
$age = $now_year - $birth_year;
}else if($birth_month == $now_month){
if($brith_day <= $now_day)
$age = $now_year - $birth_year;
else
$age = $now_year - $birth_year -1;
}else{
$age = $now_year - $birth_year-1;
}
return $age;
}
getManNai(1990,01,05);