js得到当前月第一天为星期几,当前月共有多少天

var date = new Date();
	 date.setDate(1);
	 var week = date.getDay();
	 var weeks;
	 var constDayOfWeek = [];
	 for(var j=week;j<=7+week;j++){
		if((j%7)==1){
			weeks="一";
		}else if((j%7)==2){
			weeks="二";
		}else if((j%7)==3){
			weeks="三";
		}else if((j%7)==4){
			weeks="四";
		}else if((j%7)==5){
			weeks="五";
		}else if((j%7)==6){
			weeks="六";
		}else if((j%7)==0){
			weeks="日";
		}
		constDayOfWeek.push(weeks);	
	 }
	 
	 date.setMonth(date.getMonth() + 1);
	 var lastDate = new Date(date - 3600000*24);
	 //alert("本月最后一天是 " + lastDate.getDate());

你可能感兴趣的:(js)