Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.toLocaleTimeString

Formats a time without the date by language rules.

Available since: ES1

Syntax

date.toLocaleTimeString(locales, options)

Parameters

ParameterTypeDescription
localesstringOptional. The language and region.
optionsobjectOptional. 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 PM

Hours 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:05

Notes

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

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.

Thanks for reading!

Donate to the site — we work hard for you.