Z .
Z .

Reputation: 12837

Date filter not working

Long story short, I'm trying to display a date that came from json.

This is what I tried:

{{ item.CreateDate | date }}
{{ item.CreateDate | date : 'MM/dd/yyyy' }}

This is what I get: /Date(1413010800000)/

I want to get 10/14/2014

What am I doing wrong? Thanks

Upvotes: 0

Views: 274

Answers (1)

Andy Ecca
Andy Ecca

Reputation: 1969

Try

{{ item.CreateDate | msDate | date : 'MM/dd/yyyy' }}

And the filter

app.filter('msDate', function () {
  return function (item) {
    return new Date(parseInt(item.substr(6)));
  };
});

Thanks @Brocco.

Upvotes: 1

Related Questions