此代码应记录所有天为给定月份:31天2月在Date对象
var date = new Date(2012,2,1);
var thisMonth = date.getMonth();
while(date.getMonth()==thisMonth) { // 31 steps ???
console.log(date.getMonth(),date.getDate());
date.setDate(date.getDate()+1);
}
它非常适用每月但二月。任何想法都可以抓住?
你用什么指数二月份....? 1或2 ...? – 2013-04-29 10:07:01
几个月的索引从0开始。请参见[this fiddle](http://jsfiddle.net/jamesallardice/HSECS/)。 – 2013-04-29 10:07:23