$scope.currentDate=new Date();
$scope.currentDate=$filter('date')(new Date(),'yyyy-MM-dd');
//Value received from web service stored in data
$scope.login=data.last_login_server;
$scope.login=$filter('date')($scope.login,'yyyy-MM-dd');
if(($scope.login.getDate() + 30) == $scope.currentdate)
alert('Time limit exceeded');
答案 0 :(得分:0)
您可以从两个日期开始以毫秒为单位获取经过的时间。
var now = new Date();
var lastTime = new Date(/*data.last_login_server*/);
// set a date 30 days ago for demonstration
lastTime.setDate(now.getDate() - 30);
var milliseconds = (now - lastTime);
var days = milliseconds / 1000 / 3600 / 24;
alert(days);