Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Javascript date toLocaleString ignores locale

I have en_GB as locale on both my system and my browser.

browser

system

When I run (new Date()).toLocaleString() in the browser console I get "12/1/2021, 1:56:32 PM" aka the en_US format. However, if I set the locale via Chromium Dev Tools Sensors tab to en_GB and reload the page, the function returns "01/12/2021, 14:05:02" aka the proper en_GB formatting.

Overriding locale with Dev Tools

So my questions is whether or not this is an issue with my system/browser. If it's not an issue with my configuraiton, then how why does that dev tools feature fix the issue? How exactly does it change the global javascript values and why doesn't the browser set those automatically according to my default language?

I am aware of workarounds such as passing the navigator.language manually as an argument to toLocaleString function or using a library like moment or dayjs to manage my dates and formatting, but this questions just about the unpredictable behaviour of toLocaleString as I have described above.

Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Turns out I have had export LANG=en_US.utf8 in my .bashrc. Since it is apparently sourced before starting any program on my system, the browsers used en_US instead of my actual system language.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda