Format UTC using datepipe

Viewed 13307

I want to format the UTC datetime to 'dd/MM/yyyy hh:mm:ss a'. I tried this using the datepipe. However it converts it to the localtime. How can I format UTC to the required format.

Stackblitz link: https://stackblitz.com/edit/angular-oxr43w

Thanks in advance.

2 Answers

A simpler solution is to use the short parameter value set to "UTC":

<p>
  UTC: {{date | date: 'short':'UTC'}}
</p>

Angular pipes cast dates to locale timezone unless you specify it: angular -datepipes

Related