Format date with timezone in angularjs -


using angularjs 1.2.26 cant format date input desired timezone, here's example: http://plnkr.co/edit/cxcqor3awcl1nfrczyjx?p=preview

{{'2015-07-10t12:37:08z' | date : "mmmm d, y 'at' h:mma z" : 'america/bahia'}} 

and

{{'2015-07-10t12:37:08z' | date : "mmmm d, y 'at' h:mma z" : 'europe/paris'}} 

gave same output respecting browser's local timezone , ignoring timezone i've set.

there 2 problems:

  • the time zone support looks introduced post-1.2.26
  • the time zone support doesn't take arbitrary tzdb id. docs v1.4.1:

    timezone used formatting. understands utc/gmt , continental time zone abbreviations, general use, use time zone offset, example, '+0430' (4 hours, 30 minutes east of greenwich meridian) if not specified, timezone of browser used.

    in v1.3.16 it's more restricted:

    timezone used formatting. right now, 'utc' supported. if not specified, timezone of browser used.

so if change example use:

<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.2/angular.js" data-semver="1.4.2"></script> 

and then:

<span>{{'2015-07-10t12:37:08' | date : "mmmm d, y 'at' h:mma z" : 'pst'}}</span> <br/> <span>{{'2015-07-10t12:37:08' | date : "mmmm d, y 'at' h:mma z" : 'edt'}}</span> 

(for example) you'll output of:

july 10, 2015 @ 3:37am -0800  july 10, 2015 @ 7:37am -0400 

Comments