'wrong format date mat data picker

I want show date with this format DD/MM/YYYY. I need to use italian languages with data picker and this format DD/MM/YYYY. In my app.module I do this:

export const DD_MM_YYYY_Format = {
  parse: {
      dateInput: 'DD/MM/YYYY',
  },
  display: {
      dateInput: 'DD/MM/YYYY',
      monthYearLabel: 'MMM YYYY',
      dateA11yLabel: 'LL',
      monthYearA11yLabel: 'MMMM YYYY',
  },
};

and after I do in my providers :

 { provide: MAT_DATE_LOCALE, useValue: 'it-IT' },
   {provide: MAT_DATE_FORMATS, useValue: DD_MM_YYYY_Format},

So I do in my component and the format is not properly correctly. the result is this:

enter image description here

the problem is that I want the format '02/03/2022' and not '2/3/2022'



Solution 1:[1]

Add a date pipe to your input field ref angular.io/api/common/DatePipe.

You seem to be looking for this pipe:

{{ dateObj | date:'dd/MM/YYYY' }}  

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 James D