I'm getting data back from the server like this:
'2015-03-05T16:51:56+00:00'
Using Angular, I'd like to display this date/time as an Eastern Time date. Is there a way to specify a different timezone with Angular? I'm doing something like:
{{ myDate | date: 'medium' }}
Which gives back:
Mar 5, 2015 11:51:56 AM
But I'd like it to display as:
Mar 5, 2015 4:51:56 PM
From the angularJS dateFilter
docs
timezone
(optional) stringTimezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the timezone of the browser will be used.
So try:
{{ myDate | date: 'medium' : -0500 }}
The syntax for the date
filter in HTML template binding since 1.3 allows for an optional timezone
field:
{{ date_expression | date : format : timezone}}
However, 1.3 only supports the UTC timeszone.
Timezone to be used for formatting. Right now, only 'UTC' is supported. If not specified, the timezone of the browser will be used
In the 1.4 beta, it now supports more than just UTC:
Timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the timezone of the browser will be used.
You could specify the timezone or the offset to use:
{{ myDate | date: 'medium' | timezone: '+0430'}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With