1

I want to convert UTC time to specific timezone using angular DatePipe.

Without appending timezone, transform method converts UTC to local time which i don't want. here's the code.

punch_time = this.datepipe.transform('2021-02-05T06:03:40.574000Z', 'shortTime');

above code gives output of 11:33 AM. which is local time. instead i want to get time in specific timezone for example UAE - Dubai time.

How to do this?

BLU
  • 61
  • 8

1 Answers1

2

Angular datePipe accepts a timezone parameter. But instead of trying to send the ISO8601 timezone abbreviations, I've found sending the time offset required work without any issues.

Try the following

punch_time = this.datepipe.transform('2021-02-05T06:03:40.574000Z', 'shortTime', '+4000');
ruth
  • 29,535
  • 4
  • 30
  • 57