我正在构建一个需要用户选择日期的系统。从那天起,我需要为特定目的再添加几天。 论文是用户的输入:
<input type="date" ng-model="req.pickup_date" required>
<input type="number" min="1" max="60" ng-model="req.days" required>
&#13;
那么如何以正确的方式做这样的事情呢?
var c = 86400000;
$scope.req.return_date = new Date($scope.req.pickup_date + (2 * c));
&#13;
答案 0 :(得分:0)
在此处查看答案:How to add number of days to today's date?
您可以使用此代码:
$scope.req.return_date = new Date($scope.req.pickup_date);
$scope.req.return_date.setDate($scope.req.return_date.getDate() + $scope.req.days);
console.log($scope.req.return_date);
// req.days has been added to the return date