Localized date and time display
Render dates and times according to a user's language and regional conventions.
JavaScript · Module
Intl is the namespace for JavaScript's ECMAScript Internationalization API. Its constructors and utilities provide locale-sensitive comparison, formatting, and other language-aware operations.
Intl is a namespace object for the ECMAScript Internationalization API. Its constructors and static utilities support locale-sensitive comparison, number formatting, date and time formatting, and other language-aware operations; it is used through its static members and constructors rather than called or instantiated itself.
| Name | Type | Description |
|---|---|---|
locales | string | Intl.Locale | string[] | undefined | Preferred locale identifier, an Intl.Locale object, a locale list, or undefined to use the default locale. |
options | object | undefined | An object whose available properties depend on the constructor or function using it. |
Intl.Locale instance.new Intl(); the namespace itself cannot be constructed.Intl() or applying new to Intl throws instead of performing an operation.const locale = navigator.language;
const date = new Intl.DateTimeFormat(locale, {
dateStyle: "medium",
}).format(new Date());
const amount = new Intl.NumberFormat(locale, {
style: "currency",
currency: "USD",
}).format(1234.5);
console.log(`${date}: ${amount}`);The formatters use the browser's preferred locale to produce localized date and currency strings.
Render dates and times according to a user's language and regional conventions.
Format prices, measurements, and quantities using locale-appropriate separators and patterns.
Compare or sort user-facing text according to language-specific collation rules.
Inspect or normalize locale preferences before selecting an internationalized UI behavior.
Intl in JavaScript?Intl is a namespace object that groups the ECMAScript Internationalization API. It provides constructors and shared functionality for locale-sensitive tasks such as string comparison, number formatting, and date and time formatting.
Follow-up: How are requested locales handled? Constructors and language-sensitive methods negotiate the requested locale list against supported locales, using the localeMatcher option when applicable.
Intl be called or instantiated directly?Intl itself is not constructible or callable, and its members are static. Individual API objects, such as Intl.NumberFormat, are created through their own constructors.
Follow-up: What happens when no locale is supplied? The implementation uses its default locale, while an explicitly supplied locale or locale list expresses the preferred language or region.
locales and options arguments?The locales argument identifies the preferred locale for an operation. It can be omitted, supplied as one locale identifier or Intl.Locale object, or supplied as a list of locales; the implementation selects the closest supported locale.
Follow-up: What does options do? It is an object whose properties vary by constructor or function and can control formatting or locale negotiation behavior.
Intl.CollatorIntl.DateTimeFormatIntl.DisplayNamesIntl.ListFormatIntl.LocaleIntl.NumberFormatIntl.PluralRulesIntl.RelativeTimeFormat