0

I'm building a system that need user to pick a date. And from that date I need to add few more days for certain purposes. Theses are the user's input:

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

So how do I do something like this in the correct way?

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

1 Answers1

0

Check out the answer here : How to add number of days to today's date?

You can use this code:

$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
Community
  • 1
  • 1
Moshe Karmel
  • 459
  • 4
  • 9