From 78d43a1b1e5e06cd237a6a6d06f2edf234c88e60 Mon Sep 17 00:00:00 2001 From: Princi Vershwal Date: Tue, 24 Oct 2023 13:27:13 +0530 Subject: [PATCH] Using browser local to display time format (#18734) Ref: https://www.notion.so/ghost/Localise-formatting-of-Timezone-e12b49ed84a74dfeb4fe922514a08832 --- apps/admin-x-settings/src/utils/helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/admin-x-settings/src/utils/helpers.ts b/apps/admin-x-settings/src/utils/helpers.ts index e4708e2793..2622e5c031 100644 --- a/apps/admin-x-settings/src/utils/helpers.ts +++ b/apps/admin-x-settings/src/utils/helpers.ts @@ -25,7 +25,8 @@ export function resolveAsset(assetPath: string, relativeTo: string) { export function getLocalTime(timeZone: string) { const date = new Date(); const options = {timeZone: timeZone}; - const localTime = date.toLocaleString('en-US', options); + const userLocale = navigator.language.startsWith('en') ? navigator.language : 'en-US'; + const localTime = date.toLocaleString(userLocale, options); return localTime; }