Has Chrome stopped supporting Intl function?

916 Views Asked by At

I am using chrome browser (Version 92.0.4515.131).

I found that the support for JavaScript Intl is not functioning properly in Chrome browser.

const formattedDate = new Intl.DateTimeFormat('nb-NO', {
  "year": "numeric",
  "month": "2-digit",
  "day": "2-digit"
}).format(new Date('2021-08-02'));

console.log(formattedDate);

Chrome is giving "08/02/2021" as a result, instead of the expected "02.08.2021" like in Firefox.

The JavaScript functionality is defined in ECMA and MDN mention for the browser compatibility.

Is there is any modification we need to add in order for this to work properly in Chrome?

2

There are 2 best solutions below

1
Quentin On

See Intl.ListFormat.supportedLocalesOf()

When I run Intl.ListFormat.supportedLocalesOf(['en', 'de', 'nb']) in Chrome and Firefox:

  • Chrome reports that it supports English and German
  • Firefox reports that it supports English, German and Norwegian

The problem isn't lack of support for Intl (which would throw an error if it wasn't supported) but the nb-NO locale specifically.

0
Bjerke On

This seems to be an issue with chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1233509&q=locale&can=2

Hopefully it will be solved soon.