Update date format to user local format
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn clear
command. - I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
Doc pages have e.g. Last updated on 4/25/2022 by Simen Bekkhus
, which is the US locale. This makes the date ambiguous when the date is 1-12. While that would still be the case if the date uses the local locale, at least I’d read it correctly 😅
Reproducible demo
https://github.com/facebook/jest
Steps to reproduce
Look at the bottom of e.g. https://jestjs.io/docs/jest-object#fake-timers
Expected behavior
For non-US locales, that it says Last updated on 25/04/2022 by Simen Bekkhus
, like new Intl.DateTimeFormat().format()
returns when I run it in the Chrome console. I.e. uses local locale, not US locale.
Actual behavior
It uses US date formatting.
Your environment
- Public source code:
- Public site URL: https://jestjs.io/
- Docusaurus version used:
2.0.0-beta.18
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 100 (and whatever version of node Netlify uses)
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS 12.13.1
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Change the date format for each User - Salesforce Help
Change how the date format is displayed by updating the "Locale" set on the User record. · Change the Date format in Classic....
Read more >Display date/time in user's locale format and time offset
To convert date to local date use toLocaleDateString() method. var date = (new ...
Read more >Formatting the user's local date-times using Hooks - Fly.io
Based on the user's default locale and timezone, this method returns the local date as a string.
Read more >How to change date format depends on user locale?
There is a Date method for that: format(). Returns the Date as a string using the locale of the context user. Here are...
Read more >Date and time localization - Lokalise Blog
In the long date format, the syntax of the date is MMM DD YYYY . Here, the month and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Will keep this open until we provide more flexibility for users to define how they want to handle blog/doc date formats
See also https://github.com/facebook/docusaurus/pull/7673#issuecomment-1170186409
I’m not sure what scope you want that ISO format to apply: (a) to all locales, or (b) just to
en
, or © be a user config?For (a), I’d say using the locale date format is usually not that ambiguous. e.g.
fr
would format the date asdd-MM-yyyy
which seems reasonable to every French-speaking people(actually, maybe not, sincefr-CA
formats it asyyyy-MM-dd
, so a fair proportion of them don’t format asdd-MM-yyyy
). It’s just English that has this complication😅 And for ©, when it comes to i18n, it’s usually not the site creator’s call to say what to display, so a config option doesn’t seem right to me either. So the solutions I can think of are:en
(which is the default anyways, so it is already special in some sense) where we always useyyyy-MM-dd
Both seem like good ways out, but the second way could potentially solve other edge-cases if there are other diverging date formats in other locales that I’m not aware of.