6

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
  • 143,271
  • 52
  • 317
  • 404
  • 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
  • I think that what you were looking for was [here](https://stackoverflow.com/a/9893752/17089665) – S. Dre Aug 05 '22 at 07:22
  • Does this answer your question? [Get Locale Short Date Format using javascript](https://stackoverflow.com/questions/2388115/get-locale-short-date-format-using-javascript) – S. Dre Aug 05 '22 at 07:23

1 Answers1

0

Here is the List I found, not exhaustive though.

  1. https://html-shark.com/HTML/LanguageCodes.htm (Covers a lot)
  2. http://www.lingoes.net/en/translator/langcode.htm (backup)

EDITED: a more comprehensive list https://gist.github.com/mlconnor/1887156

Adeyemi Simeon
  • 140
  • 2
  • 6