I have JSON Data which consist of Array of Data and I wanted to find the count tags based on this day, this week this month data
In the JSON Data I am getting the date Format as
2017-08-10T13:14:53.000+0000
I have JSON Data which consist of Array of Data and I wanted to find the count tags based on this day, this week this month data
In the JSON Data I am getting the date Format as
2017-08-10T13:14:53.000+0000
Maybe help you. You should get day and week and month of base date as you see. then loop through data and get issue date ("created": "2017-08-10T13:14:53.000+0000"
) and create new date. so check it with base day,week, month of base date and go on.
var app = angular.module('myApp', []);
app.controller("Controller", ["$scope", "$http", "$filter", "$window",
function($scope, $http, $filter, $window) {
$scope.data = {
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 257,
"issues": [{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "1578077",
"fields": {
"created": "2017-08-10T13:14:53.000+0000",
"resolutiondate": null,
"status": {
"name": "IN PROGRESS",
"id": "10548"
}
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "1562078",
"fields": {
"created": "2017-07-27T03:42:24.000+0000",
"resolutiondate": null,
"status": {
"name": "To Do",
"id": "10548"
}
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "1562078",
"fields": {
"created": "2017-08-20T03:42:24.000+0000",
"resolutiondate": null,
"status": {
"name": "To Do",
"id": "10549"
}
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"fields": {
"created": "2017-08-11T13:03:52.000+0000",
"resolutiondate": null,
"status": {
"name": "IN PROGRESS",
"id": "3"
}
},
"id": "1579217"
}
]
}
var d = new Date("2017-08-10T13:14:53.000+0000");
var day = d.getDay();
var month = d.getMonth();
$scope.dayCount = 0;
$scope.monthEventCount = 0
$scope.today = new Date();
//var week =
$scope.findTheValue = function() {
angular.forEach($scope.data.issues, function(issue) {
var issueDate = new Date(issue.fields.created);
if (issueDate.setHours(0,0,0,0) == $scope.today.setHours(0,0,0,0))
$scope.dayCount = $scope.dayCount + 1;
if (issueDate.getMonth() == month)
$scope.monthEventCount = $scope.monthEventCount + 1;
})
}
}
]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="Controller">
<button type="button" ng-click="findTheValue();">Submit</button>
<div>{{dayCount}}</div>
<div>{{monthEventCount}}</div>
{{date}}
</div>
</div>