diff --git a/src/common/datetime/format_date_time.ts b/src/common/datetime/format_date_time.ts index 0b91a40b81..eddc74aec4 100644 --- a/src/common/datetime/format_date_time.ts +++ b/src/common/datetime/format_date_time.ts @@ -16,7 +16,7 @@ const formatDateTimeMem = memoizeOne( year: "numeric", month: "long", day: "numeric", - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", hour12: useAmPm(locale), }) @@ -34,7 +34,7 @@ const formatDateTimeWithSecondsMem = memoizeOne( year: "numeric", month: "long", day: "numeric", - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", second: "2-digit", hour12: useAmPm(locale), diff --git a/src/common/datetime/format_time.ts b/src/common/datetime/format_time.ts index a20e1feef5..c1511fb8eb 100644 --- a/src/common/datetime/format_time.ts +++ b/src/common/datetime/format_time.ts @@ -13,7 +13,7 @@ export const formatTime = toLocaleTimeStringSupportsOptions const formatTimeMem = memoizeOne( (locale: FrontendLocaleData) => new Intl.DateTimeFormat(locale.language, { - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", hour12: useAmPm(locale), }) @@ -28,7 +28,7 @@ export const formatTimeWithSeconds = toLocaleTimeStringSupportsOptions const formatTimeWithSecondsMem = memoizeOne( (locale: FrontendLocaleData) => new Intl.DateTimeFormat(locale.language, { - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", second: "2-digit", hour12: useAmPm(locale), @@ -45,7 +45,7 @@ const formatTimeWeekdayMem = memoizeOne( (locale: FrontendLocaleData) => new Intl.DateTimeFormat(locale.language, { weekday: "long", - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", hour12: useAmPm(locale), })