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] wrong week days when using `formatDate`

See original GitHub issue

With error:

image

const dateTimeFormat = new Intl.DateTimeFormat('en-AU');
<DatePicker DateTimeFormat={() => dateTimeFormat} formatDate={dateTimeFormat.format} locale="en-AU" />

Without error

image

<DatePicker />

I think the component is using the formatDate method everywhere and that’s causing the error

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

3reactions
tintin1343commented, Apr 21, 2016

Try using this: let DateTimeFormat = global.Intl.DateTimeFormat;

<DatePicker hintText=“en-AU locale” DateTimeFormat={DateTimeFormat} locale=“en-AU” formatDate={new DateTimeFormat(‘en-AU’, { day: ‘numeric’, month: ‘numeric’, year: ‘numeric’, }).format} firstDayOfWeek={0} />

and let me know.

1reaction
luisrudgecommented, Apr 21, 2016

I think the issue is because I’m not passing the DateTimeFormat constructor, I’m passing the created object (DateTimeFormat={() => aussieFormat}).

using this works:

    let DateTimeFormat;
    if (areIntlLocalesSupported(['en-AU'])) {
      DateTimeFormat = Intl.DateTimeFormat;
    } else {
      const IntlPolyfill = require('intl');
      DateTimeFormat = IntlPolyfill.DateTimeFormat;
      require('intl/locale-data/jsonp/en-AU');
    }
    <DatePicker DateTimeFormat={DateTimeFormat} locale="en-AU" />
Read more comments on GitHub >

github_iconTop Results From Across the Web

[DatePicker] wrong week days when using formatDate #4052
Your DatePicker looks weird. What version of MUI are you using? Could you update it and try. I tried reproducing your issue, had...
Read more >
jQuery UI DatePicker - return wrong Date Format
Solution #2 (Recommended): ... I split the date_text string using split(".") and now have an array with day in from[0], month in from[1]...
Read more >
Issues with Date Picker / Date Formats
Solved: Hello Community, I'm having some problems getting my dates to display / submit correctly using a Datepicker linked to a SharePoint List....
Read more >
jQuery UI Datepicker
Specify either an actual date via a Date object or as a string in the current dateFormat , or a number of days...
Read more >
jquery ui datepicker showing wrong date — DataTables forums
I want to use the jquery UI datepicker in this case as it is more customizable.(I only want the user to select month/year...
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