0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Using browser local to display time format (#18734)

Ref:
https://www.notion.so/ghost/Localise-formatting-of-Timezone-e12b49ed84a74dfeb4fe922514a08832
This commit is contained in:
Princi Vershwal 2023-10-24 13:27:13 +05:30 committed by GitHub
parent 5844e5c9f1
commit 78d43a1b1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}