2011年12月

PHP跟据生日获取年龄

/**
* @desc 根据生日获取年龄
* @param string $birthday
* @return integer
*/
function getAge($birthday) {
$birthday=getDate(strtotime($birthday));
$now=getDate();
$month=0;
if($now['month']>$birthday['month'])
$month=1;
if($now['month']==$birthday['month'])
if($now['mday']>=$birthday['mday'])
$month=1;
return $now['year']-$birthday['year']+$month;
}