日期计算MEAN堆栈

时间:2017-05-17 19:20:14

标签: javascript html angularjs html5 mean-stack

我正在构建一个需要用户选择日期的系统。从那天起,我需要为特定目的再添加几天。 论文是用户的输入:



<input type="date" ng-model="req.pickup_date" required>
<input type="number" min="1" max="60" ng-model="req.days" required>
&#13;
&#13;
&#13;

那么如何以正确的方式做这样的事情呢?

&#13;
&#13;
var c = 86400000;
$scope.req.return_date = new Date($scope.req.pickup_date + (2 * c));
&#13;
&#13;
&#13;

1 个答案:

答案 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