I needed to be able to calculate the difference between two days, inclusive, and display the difference. Ideally this would be via an angular filter so it can be used all ov
JS Filter
generalFilters.filter('dateDiff', function () {
var magicNumber = (1000 * 60 * 60 * 24);
return function (toDate, fromDate) {
if(toDate && fromDate){
var dayDiff = Math.floor((toDate - fromDate) / magicNumber);
if (angular.isNumber(dayDiff)){
return dayDiff + 1;
}
}
};
});
HTML to display the value.
{{entry.toStr | dateDiff:entry.fromStr}}