From 7169314b54ae54f57dcf88adc461072069e19083 Mon Sep 17 00:00:00 2001 From: yanzai Date: Tue, 26 Mar 2024 11:28:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B965=E5=B2=81=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/YeWu/AppointmentService.php | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Laravel/app/Services/Admin/YeWu/AppointmentService.php b/Laravel/app/Services/Admin/YeWu/AppointmentService.php index ae875a1..712bb04 100644 --- a/Laravel/app/Services/Admin/YeWu/AppointmentService.php +++ b/Laravel/app/Services/Admin/YeWu/AppointmentService.php @@ -132,15 +132,23 @@ class AppointmentService $birthMonth = substr($idCard, 10, 2); $birthDay = substr($idCard, 12, 2); - // 将出生日期转换为日期对象 - $birthdate = new DateTime($birthYear . '-' . $birthMonth . '-' . $birthDay); - - // 获取当前日期 - $currentDate = new DateTime(); - - // 计算年龄差 - $ageDiff = $birthdate->diff($currentDate)->y; - +// // 将出生日期转换为日期对象 +// $birthdate = new DateTime($birthYear . '-' . $birthMonth . '-' . $birthDay); +// +// // 获取当前日期 +// $currentDate = new DateTime(); +// +// // 计算年龄差 +// $ageDiff = $birthdate->diff($currentDate)->y; + + + $birthYear = substr($idCard, 6, 4); // 例如,假设身份证号的格式为:XXXXXXYYMMDDZZZZ + $currentYear = date('Y'); // 获取当前年份 + + // 将字符串转换为整数 + $birthYear = intval($birthYear); + $currentYear = intval($currentYear); + $ageDiff= $currentYear - $birthYear; // 判断年龄是否大于65岁 if ($ageDiff >= 65) { return true;