fix: 设备日志页 fmtTime 修复时区偏移 8 小时
Flask jsonify 把 MySQL DATETIME 序列化为 '... GMT' 但实际是本地时间。 JS new Date() 按 GMT 解析后在 UTC+8 显示会多 8 小时。 统一去除 GMT 后缀再解析(与 test_op.js 相同方案)。
This commit is contained in:
@@ -92,7 +92,10 @@ function eventLabel(t) {
|
||||
|
||||
function fmtTime(v) {
|
||||
if (!v) return '-';
|
||||
const d = new Date(v);
|
||||
// Flask jsonify 给 MySQL DATETIME 加 "GMT" 后缀,但实际值是服务器本地时间(UTC+8)
|
||||
// 去掉 "GMT" 让 JS 按本地时间解析,避免时区偏移 8 小时
|
||||
const cleaned = String(v).replace(/ GMT$/, '');
|
||||
const d = new Date(cleaned);
|
||||
if (isNaN(d.getTime())) return String(v).substring(0, 19);
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0');
|
||||
|
||||
Reference in New Issue
Block a user