question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Datepicker] Format not maintaining

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I set a format used in the EU for the date

mask="__-__-____"
inputFormat="DD-MM-YYYY"

However after changing the value e.g (feb 3rd) the format of the date picker reverts back the original america format (MM-DD-YYYY)

Expected behavior 🤔

I expect the format to be applied on change and for default value.

Steps to reproduce 🕹

https://codesandbox.io/s/basicdatepicker-material-demo-forked-2p2uw0

Steps:

  1. Set the date to febuary (3rd)
  2. expect to see (03-02-2022)
  3. but instead see (02-03-2022)

Context 🔦

No response

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kaykhancheckpointcommented, Mar 9, 2022

@LazeBear

hmm i forgot what is specifically was but here is the code that eventually worked for me.

<LocalizationProvider dateAdapter={AdapterDateFns}>
      <DatePicker
          disableFuture
          value={searchState.date}
          onChange={(value) => {
              setSearchState({
                  ...searchState,
                  date: DateFnsFormat(value, "yyyy-MM-dd"),
              });
          }}
          mask="____-__-__"
        inputFormat="yyyy-MM-dd"
        label="Date"
        renderInput={(params) => <TextField {...params} />}
    />
</LocalizationProvider>
0reactions
github-actions[bot]commented, Jun 10, 2022

👋 Thanks for using MUI Core!

We use GitHub issues exclusively as a bug and feature requests tracker, however, this issue appears to be a support request.

For support, please check out https://mui.com/getting-started/support/. Thanks!

If you have a question on StackOverflow, you are welcome to link to it here, it might help others. If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jquery datepicker format date not working - Stack Overflow
Try just format option not dateFormat $('#datepicker').datepicker({ ... Depending on the version of datepicker being used, the correct format may be:
Read more >
Issues with Date Picker changing the date format in randomly
Solved: Hi guys, I have a very annoying issue when inputting dates using a date picker. When i input a date, The information...
Read more >
How to deal with the date format with DatePicker
We have bound our structure field to the value attribute of the DatePicker. We have maintained the valueFormat=yyyyMMdd as this is the internal ......
Read more >
Setting jQuery UI Datepicker's dateFormat should not ... - Drupal
In a module I maintain, I already have code for that: ... Datepicker does not read the format from local settings. Using core...
Read more >
Date Picker format to MM-DD-YYYY not working - OutSystems
Good day everyone! I have a problem in formatting a date using an input widget and a date picker. I try to set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found