CKTIS / JavaScript
Date.prototype.toLocaleTimeString() — localized time formatting
toLocaleTimeString() returns a text representation of a Date object's time using the selected locale and options. It lets you choose the time zone, time components, and hour cycle without changing the date.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
date.toLocaleTimeString(locales?, options?)The catalog symbol Date.toLocaleTimeString refers to the instance method Date.prototype.toLocaleTimeString, not a static method on the Date constructor. Calling date.toLocaleTimeString(locales, options) returns a string without changing date. The parameter behavior described here applies to environments supporting ECMA-402 (Intl).
locales accepts a language tag such as pl-PL, or a list of preferred tags; omitting it selects the environment's default locale. options.timeZone selects the display zone; otherwise the environment's zone is used. The hour, minute, and second options select time components. When hour12 is not set, hourCycle: 'h23' selects hours from 0 to 23. The hour12 option takes precedence over hourCycle: if you set both hour12: true and hourCycle: 'h23', the formatter uses a 12-hour cycle. With neither a style nor specified time components, hour, minute, and second are included by default.
You can use timeStyle, such as 'short', instead of explicit component options. When formatting a valid date, combining timeStyle with a component option such as hour throws TypeError. Passing dateStyle to toLocaleTimeString() for a valid date also throws TypeError, even if it is the only option. For an invalid Date, the method returns "Invalid Date" before processing the options, so combining timeStyle with hour does not throw in that case. A receiver that is not a Date object causes TypeError.
The result is for user-facing display, not stable storage or parsing: locale data can change punctuation and spacing. The example fixes the instant, locale, UTC zone, hour cycle, and numbering system to reduce variation. For repeated formatting, consider creating one Intl.DateTimeFormat and reusing its format method.
Examples
const date = new Date('2024-01-15T13:05:09.000Z');
const text = date.toLocaleTimeString('en-GB', {
timeZone: 'UTC',
hourCycle: 'h23',
numberingSystem: 'latn',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
console.log(text);Result
13:05:09
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.