优化ui
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
export function formatLocalDateTime(value: string | null | undefined, fallback = "无") {
|
||||
if (!value) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat("zh-CN", {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: false,
|
||||
}).format(date);
|
||||
}
|
||||
Reference in New Issue
Block a user