var d = new Date();
var curMonthDays = new Date(d.getFullYear(), (d.getMonth() + 1), 0).getDate();
alert("本月共有 " + curMonthDays + " 天");
d.getMonth()+1代表下个月,月份索引从0开始,即当前月为6月时,getMonth()返回值为5,创建日期时同理
此处构造的日期为下个月的第0天,天数索引从1开始,第0天即代表上个月的最后一天
 posted on 2015-03-27 15:59  Just_Do  阅读(782)  评论(0编辑  收藏  举报