Home  >  Forum  >  Angular
Post New Query

Angular Material Datepicker format YYYY-MM-DD



Asked on July 21, 2020
How to set Angular Material Datepicker format as YYYY-MM-DD ?



Replied on July 21, 2020
You need to override MAT_DATE_FORMATS .

Create your own format, eg. MY_DATE_FORMATS and configure dateInput format as YYYY-MM-DD .

export const MY_DATE_FORMATS = {
    parse: {
      dateInput: 'YYYY-MM-DD',
    },
    display: {
      dateInput: 'YYYY-MM-DD',
      monthYearLabel: 'MMM YYYY',
      dateA11yLabel: 'LL',
      monthYearA11yLabel: 'MMMM YYYY'
    },
};

In application module, configure MAT_DATE_FORMATS

providers: [
  { provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS }
]

Find the link for reference.



Write Answer








©2020 concretepage.com | Privacy Policy | Contact Us