根据生日计算年龄

来源:互联网 发布:矩阵论戴华课后答案 编辑:程序博客网 时间:2024/04/29 08:30
function age($date){      $year_diff = '';      $time = strtotime($date);      if(FALSE === $time){          return '';      }       $date = date('Y-m-d', $time);      list($year,$month,$day) = explode("-",$date);      $year_diff = date("Y") – $year;      $month_diff = date("m") – $month;      $day_diff = date("d") – $day;      if ($day_diff < 0 || $month_diff < 0) $year_diff–;       return $year_diff;  } 

原创粉丝点击