KeyboardDatePicker doesn't work with date-fns format string
See original GitHub issueIf you don’t mind add a fun gif or meme, but no pressure
Environment
Tech | Version |
---|---|
@material-ui/pickers | ^3.2.1 |
material-ui | ^4.1.1 |
React | ^16.8.3 |
Browser | Chrome 75 |
Peer library | date-fns ^2.0.0-beta.1 |
Steps to reproduce
- Create
KeyboardDatePicker
withformat="P"
Expected behavior
The docs for format
just say “Format string”. It’s not clear to me what valid input for this format string is. I tried to use a date-fns format string, but that’s causing problems
My goal is to have a format string that respects the language setting of the user’s browser. E.g. I would like mm/dd/yyyy in English and dd/mm/yyyy in Spanish. date-fns has a format string P
that accomplishes this. The browser’s Intl
API would also do this, but there’s no way to use it in the format
option since it only accepts a string
Actual behavior
I can only type one character in the input if format="P"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (3 by maintainers)
Top Results From Across the Web
KeyboardDatePicker doesn't work with date-fns format string
Actual behavior. I can only type one character in the input if format="P".
Read more >Cannot get material-ui datepicker to work - Stack Overflow
Uncaught RangeError : Format string contains an unescaped latin ... No need to downgrade @date.io/date-fns, Just format Date properly as said ...
Read more >Date-fns format and locale problem - The freeCodeCamp Forum
Hi, I used the sample from Material UI and tried to modify it. I am having a bit of trouble trying to do...
Read more >https://auctions.truckandtrailer.co.za/res/dist/at...
node_modules/date-fns/esm/_lib/format/lightFormatters/index.js", "../../../. ... with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments.
Read more >[Solved]-Cannot get material-ui datepicker to work-Reactjs
This happens as well if you pass undefined as format string. ... No need to downgrade @date.io/date-fns, Just format Date properly as said...
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
I didn’t look at that page and was only looking at https://material-ui-pickers.dev/api/KeyboardDatePicker, which I’d expect to mention something
I’m not sure I would have understood this. Putting
mask
in backticks to indicate it’s a property might be helpful. But mainly I’m not sure from the description how I’d make sure whethermask
is being automatically generated or what is meant by robust formats.That worked! Thanks!
Feel free to close this issue. I’ll leave it open for the time being in case you want to update the docs at all. It might be helpful to add a note in the
format
docs specifying thatmask
may need to be set when changing theformat
Thank you for all your help! Our app is now working and ready to bring green power to many more homes 😃