我想获得一天的日期 - 例如1或月-1,我该如何管理?
现在我有了:
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;
});
}
}
答案 0 :(得分:1)
var today = new Date();
var yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
{p>同样适用于setMonth
和getMonth
答案 1 :(得分:0)
这就是我在项目中添加日期所做的工作。也许这会对你有帮助!
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);
});