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
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;
};
});
1 Comment
Vishnuraj
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