From d9ac34ef0f2400b3d1aa7088aa38d17dfc926b6c Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 6 May 2024 16:17:22 +0200 Subject: [PATCH] feat(post): choose date/time format from translations locale --- src/lib/utils/time-utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/time-utils.ts b/src/lib/utils/time-utils.ts index 64bbb893..05ca793b 100644 --- a/src/lib/utils/time-utils.ts +++ b/src/lib/utils/time-utils.ts @@ -1,8 +1,10 @@ +import i18next from 'i18next'; + export const getFormattedDate = (commentTimestamp: number) => { if (commentTimestamp === undefined || isNaN(commentTimestamp)) { return ''; } - const locale = Intl.DateTimeFormat().resolvedOptions().locale; + const locale = i18next.language || 'en'; const string = new Intl.DateTimeFormat(locale, { hour12: false, year: '2-digit',