角度js

时间:2016-02-16 05:56:11

标签: angularjs time ionic-framework

我想比较两个日期时间对象。但alert $scope.timeDiff显示NaN未定义。

代码:

$scope.dbDealTime =  $filter('date')(data.DealTime, 'hh:mm:ss'); 
$scope.TimeNow =  $filter('date')(new Date(), 'hh:mm:ss');

$scope.timeDiff = $scope.dbDealTime - $scope.TimeNow;
alert($scope.timeDiff);

1 个答案:

答案 0 :(得分:1)

$scope.timeDiff = data.DealTime - new Date();

然后对其应用过滤器

$filter('date')($scope.timeDiff, 'hh:mm:ss');

然后在警告中显示您想要的任何内容

alert($scope.timeDiff);