0
Get(AgrTempId) {
    this.AgreementsService.GetAgreementTemp(AgrTempId).subscribe((res: BaseResponse) => {
      debugger;
      
      this.agrTempValidFrom = new DatePipe('en-US').transform(new Date(res.data["validFrom"]), 'yyyy-MM-dd');
      this.agrTempValidTo = new DatePipe('en-US').transform(new Date(res.data["validTo"]), 'yyyy-MM-dd');
     

    },
      (error) => {
      })
  }
R. Richards
  • 24,603
  • 10
  • 64
  • 64
mo obaid
  • 17
  • 3

2 Answers2

3

You can use moment for that

moment(new Date()).format('YYYY-MM-DD');

in your case you can use this way

  this.agrTempValidFrom = new DatePipe('en-US').transform(moment(new Date(res.data["validFrom"])).format('YYYY-MM-DD'));
  this.agrTempValidTo = new DatePipe('en-US').transform(moment(new Date(res.data["validTo"])).format('YYYY-MM-DD'));
Prashanth Damam
  • 841
  • 8
  • 25
0

Have you seen Format date as dd/MM/yyyy using pipes This answer was useful to me :

var ddMMyyyy = this.datePipe.transform(new Date(),"dd-MM-yyyy");
Shima
  • 1
  • 3