import { Component } from '@angular/core';
//DATE PICKER
// Custom DateAdapter
import { MatDatepickerModule, MatNativeDateModule, NativeDateAdapter, DateAdapter, MAT_DATE_FORMATS } from '@angular/material';
const MY_DATE_FORMATS = {
parse: {
dateInput: { month: 'short', year: 'numeric', day: 'numeric' }
},
display: {
dateInput: 'input',
monthYearLabel: { year: 'numeric', month: 'short' },
dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
monthYearA11yLabel: { year: 'numeric', month: 'long' },
}
};
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
matDatepicker;
date;
ngOnInit(){
this.date = new Date();
}
changer($event){
this.matDatepicker =$event;
console.log("******date selectionner",this.matDatepicker);
console.log(this.matDatepicker.getTime()*0.001); //timestamps de la date picker
}
}
<mat-form-field>
<input
matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker (selectedChanged)="changer($event)"></mat-datepicker>
</mat-form-field>
{{ matDatepicker}}
I would like to show the Angular Material date picker component in French locale. How can this be done?