4

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?

Ivar
  • 6,138
  • 12
  • 49
  • 61
D.Waasala
  • 145
  • 6
  • "Chrome is not" — you need to tell us the behaviour you get as well as the behaviour you expect. – Quentin Aug 04 '21 at 06:55
  • The expected behavior for the above code snippet is -"02.08.2021" but what chrome returns is - "08/02/2021" – D.Waasala Aug 04 '21 at 06:59
  • by searching on can I use https://caniuse.com/?search=Intl it seem that chrome still support it, so you will have to explain what is the output and what did you tried – Thibaud Aug 04 '21 at 06:59
  • @Seren I have tried the above code snippet in chrome browser console, which gave me the output of, "08/02/2021" but what it is expected to return is, "02.08.2021" – D.Waasala Aug 04 '21 at 07:02

2 Answers2

4

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.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

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.

Bjerke
  • 156
  • 2
  • 11