angularjs1.X获取前一天日期

1 $scope.getDate = new Date();
2 
3             //可以当前日期
4             $scope.nowDate = $filter("date")($scope.getDate, "yyyy-MM-dd");
5             //获取前一天日期
6             $scope.oldDate = $filter("date")($scope.getDate - 86400000, "yyyy-MM-dd");
7             console.log($scope.nowDate,$scope.oldDate);


  注意:记得依赖注入$filter

 

  输出:2017-10-20 2017-10-19

posted @ 2017-10-20 11:07  小旺同学  阅读(2450)  评论(0编辑  收藏  举报