AngularJS : display epoch in pst/pdt using date filter

Issue

I am getting date in epoch format from the backend.

updatedOn = 1427171737000 (from backend)

I am using angular filter to display the date.

{{updatedOn | date: “MM/dd/yyyy ‘ ‘ h:mma Z” }} ==> it turns to be 2015-03-23 21:35:37 -0700

I would like my output to be displayed in PST format which will be 2015-03-24 04:35:37

Any ideas?

Solution

If you are using 1.3+ of AngularJS then you just need to pass in the timezone

{{ date_expression | date : format : timezone}}

https://code.angularjs.org/1.3.15/docs/api/ng/filter/date if you want to read further.

Answered By – Burrito

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published