Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): date formatter timezone issue (#5936)

Peng Xiao27f2209e8722
diff --git a/packages/frontend/core/src/utils/intl-formatter.ts b/packages/frontend/core/src/utils/intl-formatter.ts
index b0ebae97e6..d25de98a78 100644
--- a/packages/frontend/core/src/utils/intl-formatter.ts
+++ b/packages/frontend/core/src/utils/intl-formatter.ts
@@ -1,3 +1,5 @@
+import dayjs from 'dayjs';
+
const timeFormatter = new Intl.DateTimeFormat(undefined, {
timeStyle: 'short',
});
@@ -9,9 +11,9 @@ const dateFormatter = new Intl.DateTimeFormat(undefined, {
});
export const timestampToLocalTime = (ts: string | number) => {
- return timeFormatter.format(new Date(ts));
+ return timeFormatter.format(dayjs(ts).toDate());
};
export const timestampToLocalDate = (ts: string | number) => {
- return dateFormatter.format(new Date(ts));
+ return dateFormatter.format(dayjs(ts).toDate());
};