Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

חיפוש בתמיכה

יש להימנע מהונאות תמיכה. לעולם לא נבקש ממך להתקשר או לשלוח הודעת טקסט למספר טלפון או לשתף מידע אישי. נא לדווח על כל פעילות חשודה באמצעות באפשרות ״דיווח על שימוש לרעה״.

מידע נוסף

Should .toLocaleDateString() use your preferred language?

  • 2 תגובות
  • 1 has this problem
  • 30 views
  • תגובה אחרונה מאת BytesNZ

more options

Just noticed that a web site I am working on is displaying the wrong format for the date. I am generating date string using Date.prototype.toLocaleDateString() (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString). I have changed my preferred language in the browser preferences to be [en-NZ, en-GB, en]. Checking `navigator.language` returns "en-NZ", but running

``` date = new Date(); date.toLocaleDateString() ```

returns "3/29/2020" instead of the expected "29/03/2020" as returned by `date.toLocaleDateString('en-NZ')`

Is it just me or is this a bug?

Just noticed that a web site I am working on is displaying the wrong format for the date. I am generating date string using Date.prototype.toLocaleDateString() (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString). I have changed my preferred language in the browser preferences to be [en-NZ, en-GB, en]. Checking `navigator.language` returns "en-NZ", but running ``` date = new Date(); date.toLocaleDateString() ``` returns "3/29/2020" instead of the expected "29/03/2020" as returned by `date.toLocaleDateString('en-NZ')` Is it just me or is this a bug?

השתנתה ב־ על־ידי BytesNZ

כל התגובות (2)

more options

What is reported on the "Help -> Troubleshooting Information" (about:support) page under "Internationalization & Localization" ?

more options

Ah. Cool page (about:support). It was showing Application Settings Requested Locales ["en-US"] Available Locales ["en-US"] App Locales ["en-US"] Regional Preferences ["en-GB"] Default Locale "en-US" Operating System System Locales ["en-NZ"] Regional Preferences ["en-GB"]

I have now installed the en-GB language pack, so it is now Application Settings Requested Locales ["en-US"] Available Locales ["en-US","en-GB"] App Locales ["en-US","en-GB"] Regional Preferences ["en-GB"] Default Locale "en-US" Operating System System Locales ["en-NZ"] Regional Preferences ["en-GB"]

but still outputting en-US dates.

I have just tried installing the en-GB version of firefox dev (it is now the default download version now (I guess) that I changed my preferred language). It now displays dates as en-GB dates.

Application Settings Requested Locales ["en-GB"] Available Locales ["en-GB","en-US"] App Locales ["en-GB","en-US"] Regional Preferences ["en-GB"] Default Locale "en-GB" Operating System System Locales ["en-NZ"] Regional Preferences ["en-GB"]

I would still have thought changing the preferred language would have changed the date format though (as you have to dig to find download the browser in another locale [there is no link on the dev version download page, but I found https://www.mozilla.org/en-GB/firefox/all/#product-desktop-developer from the main firefox download page]).