4

Where can the official list of Date.prototype.toLocaleDateString formats be found? It's not linked from that MDN page, and the accepted answer to this confusingly phrased question lists a different set of formats. The CLDR database is hard to consume.

What I want is a simple map, like the one below:

const date = new Date();
for (const locale of ['en-US', 'en-GB', 'en-CA'])
  console.log(locale, '=>', date.toLocaleDateString(locale, {  }));

Bonus points for passing { month: 'short' } instead of an empty options object.

Dan Dascalescu
  • 127,343
  • 44
  • 300
  • 387
  • What do you mean by "official"? The output of [*toLocaleString*](http://ecma-international.org/ecma-262/9.0/#sec-date.prototype.tolocalestring) is either based on [*ECMA-402*](http://www.ecma-international.org/ecma-402/5.0/index.html#sec-partitiondatetimepattern) or whatever the implementation decides is appropriate. Even where ECMA-402 is supported, the format may differ between implementations. The sequence of values may also change depending on the options, e.g. it might be common in Britain to use "September 23, 2018" but the shortened version would be written "23/9/2018". – RobG Sep 27 '18 at 01:07
  • 1
    @RobG: I'm looking for a map from [all the locale codes](https://stackoverflow.com/questions/52549577/javascript-get-the-complete-list-of-locales-supported-by-the-browser) to the particular format output by `date.toLocaleDateString(locale, { })`, but decoded as `YYYY${sep}MM${sep}DD`, in whatever order these appear. – Dan Dascalescu Sep 28 '18 at 06:29

0 Answers0