My mat-datepicker
returns a Moment instead of a Date, but I need a Date to work with. In app.module I have
{ provide: LOCALE_ID, useValue: 'it' },
{ provide: MAT_DATE_LOCALE, useValue: 'it' },
{ provide: DateAdapter, useClass: MomentUtcDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
{ provide: MatPaginatorIntl, useValue: getItalianPaginatorIntl() }
where MY_FORMATS
is
export const MY_FORMATS = {
parse: {
dateInput: 'DD/MM/YYYY',
},
display: {
dateInput: 'DD/MM/YYYY',
monthYearLabel: 'MM YYYY',
dateA11yLabel: 'DD/MM/YYYY',
monthYearA11yLabel: 'MM YYYY',
},
};
What do I have to change?
The problem is, that you are providing MomentUtcDateAdapter
as the DateAdapter. If you remove this provider it should work just as you expect.