0

How can I control the format of input for a datepicker individually, without changing format for the whole module?

<input matInput [matDatepicker]="dp" [formControl]="date" [format]="'DD/MM/YYYY'"> <-- is this possible?
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp></mat-datepicker>
1
  • 1
    you can change the DateAdapter for one component, e.g. stackoverflow.com/questions/54113765/…. But I'm not prety sure how do if you has two datePicker in the same component Commented Jun 7, 2020 at 10:31

1 Answer 1

0

Yes, you have to change locale of date-picker to en-GB by adding {provide: MAT_DATE_LOCALE, useValue: 'en-GB'} to provider section of you module. Like below

@NgModule({providers: [{provide: MAT_DATE_LOCALE, useValue: 'en-GB'}]})

Official doc for this

Sign up to request clarification or add additional context in comments.

1 Comment

I want to format multiple inputs within the same module differently. If I do what you suggest, then every datepicker input will have the same format. What I asked is whether it is possible to format datepicker inputs individually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.