Format UTC date and time in angular

417 Views Asked by At

I am trying to change just the UTC time and date format which I am receiving from backend.I tried datepipe to format the UTC time but it automatically converting the time to my local browser time. I want to show the same time which the backend sends.

I tried like below.

time = this.datepipe.transform(result.time,"yyyy-MM-dd hh:mm:ss" "UTC")

1

There are 1 best solutions below

1
emk On

TypeScript code:

time = this.datepipe.transform(result.time,"yyyy-MM-dd hh:mm:ss" | '+0000'")

Use this way on HTML

{{result.time | date:'dd-MMM-yyyy hh:mm:ss a' : '+0000'}}