diff --git a/edc-web/app/templates/device_logs.html b/edc-web/app/templates/device_logs.html index df0c2dc..c651cf2 100644 --- a/edc-web/app/templates/device_logs.html +++ b/edc-web/app/templates/device_logs.html @@ -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');