My database contains timestamps like 2016-12-30 00:30:10
which I retrieve using the $http
module in Angular. Below is a snippet of my Angular code:
angular
.module('sampleApp')
.controller('ReportCtrl', ReportCtrl)
.factory('Reports', Reports)
.filter('dateToISO', dateToISO);
function ReportCtrl($scope, Reports) {
$scope.returns = [];
$scope.loadReturns = function () {
Reports.getReturns().then(function (response) {
$scope.returns = response.data;
}, function (error) {
console.log(error);
})
}
}
function dateToISO() {
return function (input) {
input = new Date(input).toISOString();
return input;
};
}
In the HTML:
<tr ng-repeat="r in returns | orderBy:'-phdate'">
<td ng-bind="r.product_name"></td>
<td ng-bind="r.quantity"></td>
<td ng-bind="r.username"></td>
<td ng-bind="r.phdate | dateToISO | date:'medium'"></td>
</tr>
The current output looks like this:
https://i.sstatic.net/PxsYM.png
Now, I want to display only the data with today's date, for example, if today is 12/30/2016
. Should I handle this logic on the server-side or can it be done within Angular? Any assistance would be greatly appreciated.