Angular material manual date update for datepicker not working correctly

147 views Asked by At

I am using angular material dateipcker in my application to map the selected date in input box with dd/MM/yyyy format. But in the input field if we enter the dateformat in dd/MM/yyyy it is throwing an error as it seems it is taking format as MM/dd/yyyy for validation.

Kindly help me to fix this issue. Below is my code

html

<mat-form-field>
  <input matInput [matDatepicker]="picker" placeholder="Choose a date">
  <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

app.module.ts file

providers:[ {provide: MAT_DATE_LOCALE, useValue: 'en-GB'}]

When we click on datpicker icon it is working fine and when we try to enter it manually from input field it is throwing an error.

Current senario click on datepicker

enter image description here

Tried to modify manually

enter image description here

0

There are 0 answers