This commit is contained in:
@@ -155,7 +155,7 @@ export function formatDateRange(startDate: string, endDate: string): string {
|
||||
|
||||
/**
|
||||
* 格式化日期时间
|
||||
* @param date 日期字符串或时间戳
|
||||
* @param date 日期字符串或时间戳(支持Unix时间戳秒,自动检测)
|
||||
* @param format 格式化模板,默认 'YYYY-MM-DD HH:mm:ss'
|
||||
* @returns 格式化后的日期字符串
|
||||
*/
|
||||
@@ -165,7 +165,14 @@ export function formatDateTime(
|
||||
): string {
|
||||
if (!date) return '-'
|
||||
|
||||
const d = new Date(date)
|
||||
let d: Date
|
||||
const numDate = typeof date === 'string' ? Number(date) : date
|
||||
if (typeof numDate === 'number' && numDate > 1000000000 && numDate < 2000000000) {
|
||||
d = new Date(numDate * 1000)
|
||||
} else {
|
||||
d = new Date(date)
|
||||
}
|
||||
|
||||
if (isNaN(d.getTime())) return '-'
|
||||
|
||||
const year = d.getFullYear()
|
||||
|
||||
Reference in New Issue
Block a user