From 11b1903a6361632234cbb3a2dc5a0a2a41f0c748 Mon Sep 17 00:00:00 2001 From: liaoxinyu Date: Mon, 10 Mar 2025 16:14:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/class/date.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/class/date.js b/utils/class/date.js index 36b21ce..06a270b 100644 --- a/utils/class/date.js +++ b/utils/class/date.js @@ -125,9 +125,13 @@ function pubTime(time, isOffset = false, format = null) { * @param {string|number} dateTimeStr 接口返回的时间和日期 */ function convertTo12HourFormat(dateTimeStr) { + var date // 解析输入的日期时间字符串 - const date = new Date(dateTimeStr.replace(' ', 'T')); // 使用 T 将字符串转换为 ISO 格式 - + if(new Date(dateTimeStr.replace(' ', 'T'))=='Invalid Date'){ + date = new Date(dateTimeStr); + }else{ + date = new Date(dateTimeStr.replace(' ', 'T')); + } // 获取各个部分 const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份要加1,并填充为2位