Date.prototype.toLocaleTimeString
Formats a time without the date by language rules.
Available since: ES1
Syntax
date.toLocaleTimeString(locales, options)Parameters
| Parameter | Type | Description |
|---|---|---|
| locales | string | Optional. The language and region. |
| options | object | Optional. For example hour, minute, second, hour12, timeStyle. |
Return value
stringThe time formatted by the language rules.
Examples
24-hour and 12-hour format:
const date = new Date(2026, 2, 15, 18, 5);
console.log(date.toLocaleTimeString('de-DE'));
console.log(date.toLocaleTimeString('en-US'));Output:
18:05:00
6:05:00 PMHours and minutes only:
const date = new Date(2026, 2, 15, 18, 5);
console.log(date.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' }));Output:
18:05Notes
In the US format there is a special narrow no-break space between the time and AM/PM, not a regular one. Do not compare such strings with hand-typed text.
See also
- Date.prototype.toLocaleDateString — Formats a date without time by language rules.
- Date.prototype.toLocaleString — Formats a date together with the time by language rules.
In the tutorial
- Formatting with Intl — Locale-aware formatting of numbers, money, dates and plural words in JavaScript: toLocaleString, Intl.NumberFormat, Intl.DateTimeFormat and Intl.PluralRules.