0

I need to add a date filter which have a date property with date string value("2015-10-15T20:00:00.000Z"). This is a huge list so I can't convert every object to Date and then filter. I believe there will be any alternative to do this.

1 Answer 1

2

Try this filter:

angular.module('yourmodule').filter('datetime', function($filter) {
    return function(input) {
        var t = input.split(/[- :]/);

        // Apply each element to the Date function
        var d = new Date(t[0], t[1] - 1, t[2], t[3], t[4], t[5]);
        console.log(d);
        return d;
    };

});
Sign up to request clarification or add additional context in comments.

1 Comment

I actually need to filter out the date range without todays date. I have added one ng-show with a function passing each fromDate and toDate. new Date("2015-10-15T20:00:00.000Z") will give JS date object and return curresponding value. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.