From 61344756e9f5e944e7680f4cf68da6f744272bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=8B=87=E7=A5=A5?= <237899745@qq.com> Date: Fri, 14 Nov 2025 00:51:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E5=A4=84=E7=90=86UTC=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=B9=B6=E8=BD=AC=E6=8D=A2=E4=B8=BA=E6=9C=AC=E5=9C=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4(=E5=8C=97=E4=BA=AC=E6=97=B6=E9=97=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 formatDate 函数,识别 SQLite 返回的 UTC 时间格式 - 自动将 UTC 时间字符串转换为 ISO 格式并添加 'Z' 标记 - JavaScript Date 对象会自动将 UTC 时间转换为本地时间显示 - 修复之前显示 13号(UTC) 而不是 14号(CST) 的问题 --- frontend/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/app.js b/frontend/app.js index a41a548..a0fbcce 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -1735,7 +1735,16 @@ handleDragLeave(e) { formatDate(dateString) { if (!dateString) return '-'; - const date = new Date(dateString); + + // SQLite 返回的是 UTC 时间字符串,需要显式处理 + // 如果字符串不包含时区信息,手动添加 'Z' 标记为 UTC + let dateStr = dateString; + if (!dateStr.includes('Z') && !dateStr.includes('+') && !dateStr.includes('T')) { + // SQLite 格式: "2025-11-13 16:37:19" -> ISO格式: "2025-11-13T16:37:19Z" + dateStr = dateStr.replace(' ', 'T') + 'Z'; + } + + const date = new Date(dateStr); const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0');