Home > Mobile >  DatePipe transform shows wrong date format
DatePipe transform shows wrong date format

Time:11-14

I am using Angular version 12 and datePipe.transform, I am getting date in dd/MM/yyyy format in string and I want to bind that date in my reactive form ( to edit the form ) where I use Angular material date picker Basic Angular Date picker

Demo

I am sure I am doing something wrong but I don't know what? Can anyone help me?

CodePudding user response:

Just change this:

    const CreatedDate1 = this.datePipe.transform(CreatedDate, 'long');

P.S: You were using the string '09/11/2021' instead your formatted variable 'CreatedDate'.

By the way, as a piece of advice, it's a good practice to use "CamelCase" for naming your variables and consts in Angular ('createdDate', in your example), and leave the "PascalCase" (as 'CreatedDate') for the Interface/Classes/... I left an article about it HERE See you!

  • Related