fix: 修复分享页面时间显示问题,正确显示本地时间
- 修改 share.html 中的 formatDate 函数 - 与 app.js 保持一致的 UTC 时间处理逻辑 - 使用 toLocaleString 格式化为本地时间 - 修复分享页面显示 13号(UTC) 而不是 14号(CST) 的问题
This commit is contained in:
@@ -782,8 +782,24 @@
|
|||||||
|
|
||||||
formatDate(dateString) {
|
formatDate(dateString) {
|
||||||
if (!dateString) return '';
|
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
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user