@@ -73,7 +75,7 @@ export function EventFormatter({ row }: Props) {
— {getEventValue(row)}
-
{formatDateTime(row.createdOn)}
+
{formatDateTime(row.createdOn, locale)}
);
}
diff --git a/frontend/src/components/Table/Formatter/ValueWithDateFormatter.tsx b/frontend/src/components/Table/Formatter/ValueWithDateFormatter.tsx
index 38352b31..d83ccbfa 100644
--- a/frontend/src/components/Table/Formatter/ValueWithDateFormatter.tsx
+++ b/frontend/src/components/Table/Formatter/ValueWithDateFormatter.tsx
@@ -1,3 +1,4 @@
+import { useLocaleState } from "src/context";
import { formatDateTime, T } from "src/locale";
interface Props {
@@ -6,6 +7,7 @@ interface Props {
disabled?: boolean;
}
export function ValueWithDateFormatter({ value, createdOn, disabled }: Props) {
+ const { locale } = useLocaleState();
return (
@@ -13,7 +15,7 @@ export function ValueWithDateFormatter({ value, createdOn, disabled }: Props) {
{createdOn ? (
-
+
) : null}
diff --git a/frontend/src/locale/Utils.test.tsx b/frontend/src/locale/Utils.test.tsx
index fb262501..e998dc31 100644
--- a/frontend/src/locale/Utils.test.tsx
+++ b/frontend/src/locale/Utils.test.tsx
@@ -39,19 +39,19 @@ describe("DateFormatter", () => {
it("format date from iso date", () => {
const value = "2024-01-01T00:00:00.000Z";
const text = formatDateTime(value);
- expect(text).toBe("Monday, 01/01/2024, 12:00:00 am");
+ expect(text).toBe("1 Jan 2024, 12:00:00 am");
});
it("format date from unix timestamp number", () => {
const value = 1762476112;
const text = formatDateTime(value);
- expect(text).toBe("Friday, 07/11/2025, 12:41:52 am");
+ expect(text).toBe("7 Nov 2025, 12:41:52 am");
});
it("format date from unix timestamp string", () => {
const value = "1762476112";
const text = formatDateTime(value);
- expect(text).toBe("Friday, 07/11/2025, 12:41:52 am");
+ expect(text).toBe("7 Nov 2025, 12:41:52 am");
});
it("catch bad format from string", () => {
diff --git a/frontend/src/locale/Utils.ts b/frontend/src/locale/Utils.ts
index 018efd0b..d4224277 100644
--- a/frontend/src/locale/Utils.ts
+++ b/frontend/src/locale/Utils.ts
@@ -1,4 +1,9 @@
-import { fromUnixTime, intlFormat, parseISO } from "date-fns";
+import {
+ fromUnixTime,
+ type IntlFormatFormatOptions,
+ intlFormat,
+ parseISO,
+} from "date-fns";
const isUnixTimestamp = (value: unknown): boolean => {
if (typeof value !== "number" && typeof value !== "string") return false;
@@ -20,20 +25,19 @@ const parseDate = (value: string | number): Date | null => {
}
};
-const formatDateTime = (value: string | number): string => {
+const formatDateTime = (value: string | number, locale = "en-US"): string => {
const d = parseDate(value);
if (!d) return `${value}`;
try {
- return intlFormat(d, {
- weekday: "long",
- year: "numeric",
- month: "numeric",
- day: "numeric",
- hour: "numeric",
- minute: "numeric",
- second: "numeric",
- hour12: true,
- });
+ return intlFormat(
+ d,
+ {
+ dateStyle: "medium",
+ timeStyle: "medium",
+ hourCycle: "h12",
+ } as IntlFormatFormatOptions,
+ { locale },
+ );
} catch {
return `${value}`;
}