This is the format of date I am getting when I am using angular material datepicker....Wed Nov 21 2018 00:00:00 GMT+0530 (India Standard Time)
But I nee
No need to use MomentDateAdapter
!
Here's my solution with the least amount of code and using the MAT_NATIVE_DATE_FORMATS
.
import { MatDateFormats, MAT_NATIVE_DATE_FORMATS } from '@angular/material';
export const GRI_DATE_FORMATS: MatDateFormats = {
...MAT_NATIVE_DATE_FORMATS,
display: {
...MAT_NATIVE_DATE_FORMATS.display,
dateInput: {
year: 'numeric',
month: 'short',
day: 'numeric',
} as Intl.DateTimeFormatOptions,
}
};
@Component({
selector: 'app-vacation-wizard',
templateUrl: './vacation-wizard.component.html',
styleUrls: ['./vacation-wizard.component.scss'],
providers: [
{ provide: MAT_DATE_FORMATS, useValue: GRI_DATE_FORMATS },
]
})
Don't forget to set the appropriate language!
constructor(private readonly adapter: DateAdapter) {}
this.adapter.setLocale(this.translate.currentLang);
That's all!