Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
Differences in formatting using Intl.DateTimeFormat when including the script name

Wonder if anyone knows why when using Intl.DateTimeFormat to create a formatter using 'en-GB' as the locale will give a different output to using 'en-Latn-GB' but using 'zh-HK' and 'zh-Hant-HK' will give the same result.

See example below and JSFiddle

const date = new Date(Date.parse('2020-12-20T03:23:16'));


// Specify default date formatting for language (locale)
console.log(new Intl.DateTimeFormat('en-GB').format(date));
// expected output: "20/12/2020"
console.log(new Intl.DateTimeFormat('en-Latn-GB').format(date));
// expected output: "20/12/2020"

console.log(new Intl.DateTimeFormat('zh-HK').format(date));
// expected output: "20/12/2020"
console.log(new Intl.DateTimeFormat('zh-Hant-HK').format(date));
// expected output: "20/12/2020"

https://jsfiddle.net/aqn0e4tp/

The background to why we end up with 'en-Latn-GB' is for various reason we originally created a Intl.Locale for 'en-GB' and then called Locale.maximize() to default in some properties then after doing that using Locale.baseName as the locale when creating a formatter. In this situation Locale.baseName includes the script 'Latn'.

We can work around that issue but I am curious to know why there should be a difference.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda