Reputation: 39
I want to get the date of day - 1 or month -1 for example, how can I manage that?
For now I have that:
resolve: {
data: function($route, $http, $filter) {
var today = new Date();
var formattedDate = $filter('date')(today, 'yyyyMMdd');
return $http.get('./app/sources/stats/'+$route.current.params.mag+'/'+$route.current.params.mag+'_20170205.json').then(function(response) {
return response.data;
});
}
}
Upvotes: 0
Views: 39
Reputation: 2555
var today = new Date();
var yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
same goes for setMonth
and getMonth
Upvotes: 1
Reputation: 216
This is what i did to add days in my project. Maybe this will help you!
var app = angular.module('my-app', []);
app.controller("my-controller", function($scope) {
$scope.name = "world";
$scope.mydate = new Date("2016-08-16T15:10:10.530Z");
var numberOfDaysToAdd = 5;
$scope.newdate = $scope.mydate.setDate($scope.mydate.getDate() + numberOfDaysToAdd);
});
Upvotes: 0