From cd79496fc4017b0379a50d8dbe3c11191057fd1f 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 01:08:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E6=AD=A3=E7=A1=AE=E6=98=BE=E7=A4=BA=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 share.html 中的 formatDate 函数 - 与 app.js 保持一致的 UTC 时间处理逻辑 - 使用 toLocaleString 格式化为本地时间 - 修复分享页面显示 13号(UTC) 而不是 14号(CST) 的问题 --- frontend/share.html | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/share.html b/frontend/share.html index bb97810..ede2533 100644 --- a/frontend/share.html +++ b/frontend/share.html @@ -782,8 +782,24 @@ formatDate(dateString) { if (!dateString) return ''; - const date = new Date(dateString); - return date.toLocaleString('zh-CN'); + + // SQLite 返回的是 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); + return date.toLocaleString('zh-CN', { + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false + }); } },