Skip to content

Commit 0d62e2a

Browse files
authored
fix(web): Fix inconsistent date formatting in ApiKeysTable (#1255)
* fix(web): use `formatDateOnly` for consistent date formatting in ApiKeysTable * fix(api-keys): ensure consistent UTC-based date formatting in ApiKeysTable columns
1 parent 29da51e commit 0d62e2a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

apps/web/src/features/api-keys/components/ApiKeysTable/columns.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@owox/ui/components/dropdown-menu';
99
import { Copy, MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
1010
import RelativeTime from '@owox/ui/components/common/relative-time';
11+
import { formatDateOnly } from '../../../../utils';
1112
import { SortableHeader, ToggleColumnsHeader } from '../../../../shared/components/Table';
1213
import type { ProjectMemberApiKey } from '../../types';
1314
import toast from 'react-hot-toast';
@@ -71,7 +72,7 @@ export const getApiKeysColumns = ({
7172
const expiring = isExpiringSoon(expiresAt);
7273
return (
7374
<span className={expiring ? 'font-medium text-amber-600' : ''}>
74-
{new Date(expiresAt).toLocaleDateString()}
75+
{formatDateOnly(expiresAt, { timeZone: 'UTC' })}
7576
</span>
7677
);
7778
},

apps/web/src/utils/date-formatters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ export const formatDateShort = (date: Date | string | null): string => {
2828
}).format(d);
2929
};
3030

31-
export const formatDateOnly = (date: Date | string | null): string => {
31+
export const formatDateOnly = (
32+
date: Date | string | null,
33+
options?: { timeZone?: string }
34+
): string => {
3235
if (!date) return '—';
3336

3437
let d: Date;
@@ -44,6 +47,7 @@ export const formatDateOnly = (date: Date | string | null): string => {
4447
year: 'numeric',
4548
month: 'short',
4649
day: 'numeric',
50+
...options,
4751
}).format(d);
4852
};
4953

0 commit comments

Comments
 (0)