I am unable to change date format in my response object
How to change this ?
$http({
method: 'GET',
url: 'api/url'
}).success( function (data) {
$scope.reports = data.data;
console.log($scope.reports);
$scope.reports = $scope.reports.map(obj =>{
obj.created_at = new Date(obj.created_at);
return obj;
});
}).error(function (response){
console.log("error");
});
I try to change date format with above code
I got this response
{
"my2":[
{
"id":5,
"cuid":20,
"name":"my2",
"month":"04",
"created_at":"2018-04-01 00:00:00",
"updated_at":"2018-04-11 00:00:00",
"time":"04:32 PM",
"status":"D"
},
{
"id":4,
"cuid":20,
"name":"my2",
"month":"04",
"created_at":"2018-04-02 00:00:00",
"updated_at":"2018-04-12 00:00:00",
"time":"12:10 PM",
"status":"P"
},
],
"my":[
{
"id":44,
"cuid":21,
"name":"my",
"month":"04",
"created_at":"2018-04-12 00:00:00",
"updated_at":"2018-04-12 00:00:00",
"time":"09:08 PM",
"status":"P"
}
],
"Testing":[
{
"id":43,
"cuid":19,
"name":"Testing",
"month":"04",
"created_at":"2018-04-12 00:00:00",
"updated_at":"2018-04-12 00:00:00",
"time":"09:05 PM",
"status":"P"
}
]
}
in html i try this
{{data.created_at | date: 'dd'}}
But I got error
TypeError: $scope.reports.map is not a function
I think because of an it's object so that this problem
How to fix this ?