Skip to content

Commit

Permalink
Use Pacific Time on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Sep 18, 2024
1 parent 7a91132 commit 9d1dd9c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,22 @@ export function useObjectUrl(file?: Blob | null): string {
return url;
}

// Set timeZone to Pacific Time on server-side, use local time on client. Users
// will usually be in California, so this helps with hydration.
const dateFormat = new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
timeZone: typeof window === 'undefined' ? 'America/Los_Angeles' : undefined,
});

const dateFormatWithYear = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
timeZone: typeof window === 'undefined' ? 'America/Los_Angeles' : undefined,
});

export const formatDate = (date: Date | string, year?: boolean): string => {
Expand Down

0 comments on commit 9d1dd9c

Please sign in to comment.