eggman
eggman

Reputation: 111

Display/format UTC time in angular

I have converted a bunch of dates in my controller to UTC in order to display the in the view.

Im running into a weird problem trying to format them though..

<label>{{ '2016-07-22T10:45:00.000Z' | date : "shortTime"}}</label>

I would expect that code to display something like:

//10:45 

Instead it displays

//3:45 AM

3:45 is the local time on my computer. Any idea what causes this or how I can display 10:45?

Upvotes: 0

Views: 4643

Answers (1)

Sankar
Sankar

Reputation: 7117

Try this...

All you need to do is adding : 'UTC' after the format string.

<label>{{ '2016-07-22T10:45:00.000Z' | date:' HH:mm:ss ' : 'UTC' }}</label>

Upvotes: 3

Related Questions