i use the DatePicker from Angular Material and I would like to change the output format to yyyy/mm/dd
.
Currently it prints the date in the following format: Wed Nov 14 2018 00:00:00 GMT+0100 (Central European Normal Time)
How can I do this?
datepicker = new FormControl('', [Validators.required]);
console.log(this.datepicker.value.toString());
DatePicker
works with date object. When you print on debugging console you will always see the date in full mode.
If you want that your component shows the date in a specific format, you need to configure the library on the module.
@NgModule({
providers: [
{provide: MAT_DATE_LOCALE, useValue: 'en-GB'},
],
})
export class MyApp {}
More information are available on official documentation. I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With