bsr bsr - 13 days ago 5
AngularJS Question

Format Date time in Angular JS

How to properly display date time in Angular JS

Below output shows the input and the output (with/without angular date filter)

In: {{v.Dt}}
Angular: {{v.Dt | date:'yyyy-MM-dd HH:mm:ss Z'}}


prints:

In: 2012-10-16T17:57:28.556094Z
Angular: 2012-10-16T17:57:28.556094Z


The desired display format is
2010-10-28 23:40:23 0400
or
2010-10-28 23:40:23 EST

Answer

v.Dt is likely not a Date() object.

See http://jsfiddle.net/southerd/xG2t8/

but in your controller:

scope.v.Dt = Date.parse(scope.v.Dt);
Comments