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
  • 23,283
  • 10
  • 63
  • 62
mo obaid
  • 17
  • 2

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
  • 730
  • 5
  • 24
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