I am facing an issue in my Angular
application where I need to display the date in the 'MM/dd/yyyy
' format. The Web API is sending the date in the format of "2020-12-01T00:00:00
".
Even though I am using the DatePipe
, it does not recognize the date, unless I manually modify it to "2020-12-01T00:00:00.000Z
". Then, the DatePipe
is able to convert it to the desired 'MM/dd/yyyy
' format.
let res = this.datePipe.transform(new Date('2020-12-01T00:00:00'),'MM/dd/yyyy');
let res = this.datePipe.transform(new Date('2020-12-01T00:00:00.000Z'),'MM/dd/yyyy');
The first code snippet does not work while the second one works perfectly. However, my API sends data in the first format. Can someone assist me in converting the date from the first format to the second format using Typescript?