/** * $date是时间戳 * $type为1的时候是虚岁,2的时候是周岁 */ function getAgeByBirth($date,$type 1){ $nowYear "Y",time()); $nowMonth "m",time()); $nowDay "d",time()); $birthYear "Y",$date); $birthMonth "m",$date); $birthDay "d",$date); if1){ $age 1); }else2}{ if$birthMonth){ $age 1; }elseif($nowMonth$birthMonth){ if$birthDay){ $age 1; }else{ $age $birthYear; } }else{ $age $birthYear; } } return $age;
}
本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/3580492.html,如需转载请自行联系原作者