Reputation: 17
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) => {
})
}
Upvotes: 0
Views: 171
Reputation: 931
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'));
Upvotes: 3
Reputation: 1
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");
Upvotes: 0