Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.toLocaleString

Formats a date together with the time by language rules.

Available since: ES1

Syntax

date.toLocaleString(locales, options)

Parameters

ParameterTypeDescription
localesstringOptional. The language and region.
optionsobjectOptional. For example dateStyle, timeStyle, timeZone.

Return value

stringThe date and time formatted by the language rules.

Examples

The date and time:

const date = new Date(2026, 2, 15, 18, 5);
 
console.log(date.toLocaleString('de-DE'));
console.log(date.toLocaleString('en-GB', { dateStyle: 'long', timeStyle: 'short' }));

Output:

15.3.2026, 18:05:00
15 March 2026 at 18:05

The same moment in another time zone:

const date = new Date('2026-03-15T12:00:00Z');
 
console.log(date.toLocaleString('en-GB', { timeZone: 'Asia/Tokyo' }));
console.log(date.toLocaleString('en-GB', { timeZone: 'America/New_York' }));

Output:

15/03/2026, 21:00:00
15/03/2026, 08:00:00

Notes

The timeZone option shows the moment in any time zone without changing the date. Numbers have their own toLocaleString() — for digit grouping and currencies.

See also

Related recipes

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.