Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

355
Views
Why Chrome Date .toLocaleString() seems not to use windows.navigator.language?

According to the documentation {Date object}.toLocaleString() should use the browser default locale (when not specified).
The default locale is visible with navigator.language.

When my locale is "en-GB" I expect the output format to be DD/MM/YYY.
It is returning MM/DD/YYYY ("en" or "en-US") instead.
If I specify the locale to be "en-GB" the output is as expected.

Why the navigator.locale is not used for the .toLocaleString() ?

Date: 24 November 2021.

window.navigator.language  // default "locale" ?
new Date().toString()
new Date().toLocaleDateString()  // is not using the window.navigator.language
new Date().toLocaleDateString("en-GB")  // ok, this use the right format

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As Andreas pointed out in a comment, .toLocaleDateString() seems to have some bugs.

This workaround seems to work:

new Date().toLocaleDateString(window.navigator.language) 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!