- /**
-  * 准备工作完毕 开始计算年龄函数
-  * @param  $birthday 出生时间 uninx时间戳
-  * @param  $time 当前时间
-  **/
- function getAge($birthday){
-     //格式化出生时间年月日
-     $byear=date('Y',$birthday);
-     $bmonth=date('m',$birthday);
-     $bday=date('d',$birthday);
-  
-     //格式化当前时间年月日
-     $tyear=date('Y');
-     $tmonth=date('m');
-     $tday=date('d');
-  
-     //开始计算年龄
-     $age=$tyear-$byear;
-     if($bmonth>$tmonth || $bmonth==$tmonth && $bday>$tday){
-         $age--;
-     }
-     return $age;
- }
-  
- $riqi='1989-10-18 15:20:36';
- $uriqi=strtotime($riqi);      //将日期转化为时间戳
-  
- $age=getAge($uriqi);
- echo '<br><br>年龄计算结果:'.$age.'岁';

 
                

















