Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Intl.DateTimeFormat

Formats dates and times by language rules.

Available since: ES2015 (Intl)

Syntax

new Intl.DateTimeFormat(locales, options)

Parameters

ParameterTypeDescription
localesstringOptional. The language and region, for example en-US or de-DE.
optionsobjectOptional. dateStyle, timeStyle, weekday, year, month, day, hour, minute, timeZone and others.

Return value

Intl.DateTimeFormatAn object with the format(), formatRange() and formatToParts() methods.

Examples

One formatter for many dates:

const formatter = new Intl.DateTimeFormat('en-US', { dateStyle: 'long' });
 
console.log(formatter.format(new Date(2026, 2, 15)));
console.log(formatter.format(new Date(2026, 11, 31)));

Output:

March 15, 2026
December 31, 2026

Ready-made styles and separate parts:

const date = new Date(2026, 2, 15, 18, 5);
 
console.log(new Intl.DateTimeFormat('de-DE', { dateStyle: 'full', timeStyle: 'short' }).format(date));
console.log(new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric' }).format(date));

Output:

Sonntag, 15. März 2026 um 18:05
Mar 15

A date range:

const formatter = new Intl.DateTimeFormat('en-US', { month: 'long', day: 'numeric' });
 
console.log(formatter.formatRange(new Date(2026, 2, 15), new Date(2026, 2, 20)));

Output:

March 15 – 20

Notes

Creating a formatter once and calling format() many times is faster than calling toLocaleDateString() each time. The user's time zone comes from Intl.DateTimeFormat().resolvedOptions().timeZone.

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.