angularjs1.X获取前一天日期

时间:2024-12-18 15:05:08
 $scope.getDate = new Date();

             //可以当前日期
$scope.nowDate = $filter("date")($scope.getDate, "yyyy-MM-dd");
//获取前一天日期
$scope.oldDate = $filter("date")($scope.getDate - 86400000, "yyyy-MM-dd");
console.log($scope.nowDate,$scope.oldDate);

  注意:记得依赖注入$filter

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