2017-05-17 5 views
0

나는 사용자가 날짜를 선택해야하는 시스템을 구축 중입니다. 그리고 그 날부터 특정 목적을 위해 며칠을 더 추가해야합니다. 논문은 사용자의 입력 : 날짜 계산 평균 스택

<input type="date" ng-model="req.pickup_date" required> 
 
<input type="number" min="1" max="60" ng-model="req.days" required>
그래서 어떻게 올바른 방법으로 이런 일을합니까?

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

+1

당신은() myFunction 함수가'같은 뭔가를 할 수를 { var에 D = new Date(); var n = d.getUTCDate() + 3 } ' – Ozan

+0

내 코드에 기반을 작성할 수 있습니까? 나는 당신의 솔루션을 적용하는 방법을 정말로 모르겠다. –

+0

+ ($ scope.req.days 및 * whatever)로 추가 할 요일을 참조하십시오. – Ozan

답변

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 
+0

@moshekamel thanks! 그것은 작동합니다! –

+0

@AzinuddinAleleCha는 내 대답을 허용/정확하다고 표시 할 수 있습니까? –