1

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")

Priya
  • 13
  • 3
  • I want to just append UTC at end of all the timestamps. format the time like "2022-09-01 03:24:23 UTC" instead of showing like "2022-09-01T03:24:23.000Z" – Priya Sep 06 '22 at 09:32
  • Your code works just fine... https://stackblitz.com/edit/angular-1r6d4z?file=src/app/app.component.ts – Salketer Sep 06 '22 at 09:50
  • It's working!Thankd for your help I am struggling from morning.The problem is I missed comma in bwt the format and utc. – Priya Sep 06 '22 at 10:12

1 Answers1

0

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'}}
Santosh
  • 3,477
  • 5
  • 37
  • 75
emk
  • 1