1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| function getAge($id) { $id = $id; $birth_Date = strtotime(substr($id, 6, 8));
$Year = date('Y', $birth_Date); $Month = date('m', $birth_Date); $Day = date('d', $birth_Date);
$current_Y = date('Y'); $current_M = date('m'); $current_D = date('d');
$age = $current_Y - $Year; if ($Month > $current_M || $Month == $current_M && $Day > $current_D) { $age--; }
# 返回 return $age; }
|