# Intl

The `Intl` object is the namespace of the ECMAScript Internationalization API. It provides language-sensitive features, such as string comparison, number formatting, and date and time formatting. `Intl` holds the constructors for these features, and the functions they share with other language-sensitive methods. For more information, refer to [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) on MDN Web Docs.

In a deployed function, `Intl.DateTimeFormat().resolvedOptions()` reports the locale `en-US` and the time zone `UTC`. A date you format without a `timeZone` option is formatted in UTC.

> **Note**
>
> Under `azion dev`, the default time zone is the time zone of the machine that runs it, not `UTC`. On a machine behind UTC, the example on this page logs `5/23/2012` and `23.5.2012` locally. Pass `timeZone: 'UTC'` to format the same date in both environments.

---

## Constructors

Every constructor in this table works in a deployed function:

| Constructor                                                                                                                                                | Description                                                                                          |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [`Intl.Collator()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator)                               | Creates a collator, an object that compares strings by the rules of a language.                      |
| [`Intl.DateTimeFormat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat)             | Creates an object that formats dates and times by the rules of a language.                           |
| [`Intl.DisplayNames()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames)                   | Creates an object that translates the display names of languages, regions, and scripts consistently. |
| [`Intl.ListFormat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)                         | Creates an object that formats lists by the rules of a language.                                     |
| [`Intl.Locale()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale)                                     | Creates an object that represents a Unicode locale identifier.                                       |
| [`Intl.NumberFormat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat)                   | Creates an object that formats numbers by the rules of a language.                                   |
| [`Intl.PluralRules()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules)                      | Creates an object that applies the plural rules of a language, for plural-sensitive formatting.      |
| [`Intl.RelativeTimeFormat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat) | Creates an object that formats relative time, such as `1 day ago`, by the rules of a language.       |
| [`Intl.Segmenter()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter)                            | Creates an object that splits text into segments, such as words, by the rules of a locale.           |

---

## Methods

Both methods are static: call them on `Intl`.

| Method                                                                                                                                           | Description                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`Intl.getCanonicalLocales(locales)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales) | Returns the canonical names of the locales you pass. For example, `['EN-us', 'pt-br']` returns `['en-US', 'pt-BR']`.                                           |
| [`Intl.supportedValuesOf(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)         | Returns a sorted array of the unique values the implementation supports for `key`: calendars, collations, currencies, numbering systems, time zones, or units. |

---

## Example

This code formats a date and a number in the form that two languages and regions expect, and logs each result. The comments show the lines that a deployed function logs:

```javascript
const count = 26254.39;
const date = new Date("2012-05-24");

function log(locale) {
  console.log(
    `${new Intl.DateTimeFormat(locale).format(date)} ${new Intl.NumberFormat(
      locale,
    ).format(count)}`,
  );
}

log("en-US"); // 5/24/2012 26,254.39

log("de-DE"); // 24.5.2012 26.254,39
```

`new Date("2012-05-24")` reads a date-only string as midnight UTC, and the deployed time zone is `UTC`, so both locales print May 24. To format a date in another time zone, pass the zone in the `timeZone` option. In a deployed function, `new Date(0).toLocaleString('en-US', { timeZone: 'America/Sao_Paulo' })` returns `12/31/1969, 9:00:00 PM`.

---

## Related resources

- [Globals](/en/documentation/devtools/runtime/api-reference/azion-runtime-globals.md): The global objects, `Intl` among them, that a function uses without an import.
- [How Azion Runtime works](/en/documentation/devtools/runtime/how-it-works.md#local-and-deployed-behavior): Where `azion dev` differs from the deployed runtime, the `Intl` time zone included.
- [Web standards](/en/documentation/devtools/runtime/api-reference/web-standards.md): The JavaScript standards that Azion Runtime follows.
- [Web APIs](/en/documentation/devtools/runtime/api-reference/javascript.md): Every other Web API that a function can call in Azion Runtime.
