Date Filter showing wrong hour


#1

I’m using this custom filter for dates to format a json date field that returns: "/Date(1286746800000)/ from the webservice.

angular.module('app.jsonDate', []).filter('jsonDate', function ($filter) {
    return function (input, format) {
        return $filter('date')(parseInt(input.substr(6)), format);
    };
});

The problem is that the filter is formatting any datetime field with a 3 hour difference from the data that comes from the base.
base: 2010-10-10 15:40:00.000 and in the app it shows 18:40
base: 2014-10-20 00:00:00.000 and in the app it shows 3AM

It’s really weird. How can I fix this?


#2

Sounds like a timezone issue. Check the documentation here: https://docs.angularjs.org/api/ng/filter/date

And you might also want to look into Angular-moment here: