From 109d42797140d480c17cb12062b1ac38a5ca9b34 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 19:41:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=BD=E8=B8=AA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=BC=BA=E5=88=B6UTC+8=20=E2=80=94=20=E4=B8=8D=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E7=B3=BB=E7=BB=9F=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ethend/src/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ethend/src/index.js b/ethend/src/index.js index 8d05f03..69569c7 100644 --- a/ethend/src/index.js +++ b/ethend/src/index.js @@ -1907,12 +1907,19 @@ server.listen(ETHEND_PORT, () => { } }); -// 时间格式化:UTC+8 本地时间 +// 时间格式化:始终显示 UTC+8 (Asia/Shanghai) function formatLocalTime(ts) { var d = new Date(ts); var pad = function(n) { return n < 10 ? '0' + n : '' + n; }; - return d.getFullYear() + '-' + pad(d.getMonth()+1) + '-' + pad(d.getDate()) + ' ' + - pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()); + // Force UTC+8 regardless of system timezone + var utcH = d.getUTCHours(); + var utcM = d.getUTCMinutes(); + var utcS = d.getUTCSeconds(); + var localH = (utcH + 8) % 24; + var dayOffset = Math.floor((utcH + 8) / 24); + var localD = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate() + dayOffset)); + return localD.getUTCFullYear() + '-' + pad(localD.getUTCMonth()+1) + '-' + pad(localD.getUTCDate()) + ' ' + + pad(localH) + ':' + pad(utcM) + ':' + pad(utcS); } // 优雅退出