我需要获得月份开始日期和结束日期。
var currentDate = new Date();
var currentMonth = currentDate.getMonth();
答案 0 :(得分:3)
试试这个:
function MyCtrl($scope){
var date = new Date(), year = date.getFullYear(), month = date.getMonth();
var firstDay = new Date(year, month, 1);
var lastDay = new Date(year, month + 1, 0);
$scope.firstDay = firstDay ;
$scope.lastDay = lastDay ;
$scope.date = date ;
}
和
<div ng-app ng-controller="MyCtrl">
<ul>
<li>{{date | date:'yyyy-MM-dd'}}</li>
<li>{{firstDay | date:'yyyy-MM-dd'}}</li>
<li>{{lastDay | date:'yyyy-MM-dd'}}</li>
</ul>