I am fairly new to angularjs, but here it goes. I am able two dates through angularjs in the form dd/mm/yyyy, but what I need to do is somehow subtract the two
I tried the below one and it worked out for me
var selecteddate = new Date($rootscope.selectvalue);
$scope.firstDate = selecteddate .getTime();
$scope.SecondDate = new Date().getTime();
selected date is the one which is selected from calender and it is coming from parent scope. second date will be today's date. later i will find difference using moment diff.
var differenceinDays=parseInt(
moment.duration(
moment($scope.firstDate).diff(
moment($scope.SecondDate)
)
).asDays()
);
I am using parseInt because i want to return the integer value only
Hope this works