fix: 全站时间统一为北京时间(Asia/Shanghai)
新增 src/utils/datetime.ts 共享 formatBjTime 工具, 13 个页面(11后台+2前台) 的 toLocaleString/formatDate 改为显式北京时间。Dashboard.tsx 保留图表标签的 formatDate(split) 不受影响。
This commit is contained in:
1 parent
82afe14a23
commit
b3866f770c
12 files changed
+34
-19
No files matched your search
@@ -0,0 +1,9 @@
|
||||
// 后端按北京时间存储(无时区标记),此处显式按 Asia/Shanghai 渲染,
|
||||
// 避免浏览器本地时区导致时间显示错乱。
|
||||
export function formatBjTime(t?: string | null): string {
|
||||
if (!t) return '-';
|
||||
const iso = /[Z+]/.test(t) ? t : t + '+08:00';
|
||||
const d = new Date(iso);
|
||||
if (isNaN(d.getTime())) return t;
|
||||
return d.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false });
|
||||
}
|
||||
Reference in new issue
Block a user