fix(form): datetime如果设置为时间戳,然后初始值是一个字符串的数字显示不正确

This commit is contained in:
roymondchen 2025-12-04 15:20:30 +08:00
parent 8d55d0cd8d
commit 7e71c070f1

View File

@ -303,7 +303,7 @@ export const datetimeFormatter = (
if (v) {
let time: string | number;
if (['x', 'timestamp'].includes(format)) {
time = dayjs(v).valueOf();
time = dayjs(Number.isNaN(Number(v)) ? v : Number(v)).valueOf();
} else if ((typeof v === 'string' && v.includes('Z')) || v.constructor === Date) {
dayjs.extend(utc);
// UTC字符串时间或Date对象格式化为北京时间