我要打印从所选日期开始的天数。它不打印从当前日期到上一个日期的天数,而是打印结果(以毫秒为单位)。下面的代码段
$scope.countDays= function( d2) {
var diff = Math.abs(new Date().getTime() - d2.getTime());
alert(diff); //prints milliseconds
return diff / (1000 * 60 * 60 * 24);
};
<input ng-model="dateSelection" ng-change="countDays(dateSelection)">
如何打印实际整数中的确切天数差异并禁用将来的日期选择
答案 0 :(得分:0)
应该是
$scope.resumption = new Date(new Date().setDate(new Date().getDate() - 30));