How to Show Calendar Dates as M/D/YYY?


Topic: How to Show Calendar Dates as M/D/YYY?

HalGumbert pro premium priority asked 3 years ago

Expected behavior Show Dates as M/D/YYYY

Actual behavior Dates appear as DD/MM/YYYY

Resources (screenshots, code snippets etc.) I tried to change the formats in this code so dates in the tooltips and the date picker appear as M/D/YYY, but when changed, the calendar won't load properly. What is the correct way to change how dates are displayed?

this.formats = {
      date: 'DD/MM/YYYY',
      dateTime: this.options.twelveHour ? 'DD/MM/YYYY hh:mm A' : 'DD/MM/YYYY HH:mm',
      time: this.options.twelveHour ? 'hh:mm A' : 'HH:mm',
    };

Grzegorz Bujański staff commented 3 years ago

This is a bug. In the _createCurrentMonthDayFields method, change td.dataset.date = date; to td.dataset.date = moment(date, 'DD/MM/YYYY').format(this.formats.date);


HalGumbert pro premium priority answered 3 years ago

I applied the bug fix with no issues in all_min.js, with no negative result:

a.dataset.date = l()(o,"DD/MM/YYYY").format(this.formats.date),

However, when I changed this.formats as shown above to M/D/YYYY, an error occurred that I could not get around which could be related to changing a.dataset.date So I hard coded "M/D/YYYY" to each format in tooltips.js and templates.js.

So, I'm happy now, but it's be nice to change date, time and timestamp formats in one place.

Thank you for your help!


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.2
  • Device: MacBook Pro
  • Browser: Safari
  • OS: 12.2.1
  • Provided sample code: No
  • Provided link: No