日期:2014-05-16  浏览次数:20339 次

js得到某月总共有多少天
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
	<script type="text/javascript">
	 //方法一 
	 /**
	function DayNumOfMonth(Year,Month) 
	{ 
		var d = new Date(Year,Month,0); 
		return d.getDate(); 
	} 
	**/
	//方法二 
	
	function DayNumOfMonth(Year,Month) 
	{ 
		Month--; 
		var d = new Date(Year,Month,1); 
		d.setDate(d.getDate()+32-d.getDate()); 
		return (32-d.getDate()); 
	} 
	alert(DayNumOfMonth('2010','11'));
	
	</script>
</HEAD>

<BODY>
           
</BODY>
</HTML>

?js得到某个月的天数,以下是js中date的方法

//---------javascrip date 月是从0开始到11所以getMonth或得月得加1才是真正的月份 天数是1-31 所以天数不用

?

方法 描述 FF IE
Date() 返回当日的日期和时间。 1 3
getDate() 从 Date 对象返回一个月中的某一天 (1 ~ 31)。 1 3
getDay() 从 Date 对象返回一周中的某一天 (0 ~ 6)。 1 3
getMonth() 从 Date 对象返回月份 (0 ~ 11)。 1 3
getFullYear() 从 Date 对象以四位数字返回年份。 1 4
getYear() 请使用 getFullYear() 方法代替。 1 3
getHours() 返回 Date 对象的小时 (0 ~ 23)。 1 3
getMinutes() 返回 Date 对象的分钟 (0 ~ 59)。 1 3
getSeconds() 返回 Date 对象的秒数 (0 ~ 59)。 1 3
getMilliseconds() 返回 Date 对象的毫秒(0 ~ 999)。 1 4
getTime() 返回 1970 年 1 月 1 日至今的毫秒数。 1 3
getTimezoneOffset() 返回本地时间与格林威治标准时间 (GMT) 的分钟差。 1 3
getUTCDate() 根据世界时从 Date 对象返回月中的一天 (1 ~ 31)。 1 4
getUTCDay() 根据世界时从 Date 对象返回周中的一天 (0 ~ 6)。 1 4
getUTCMonth() 根据世界时从 Date 对象返回月份 (0 ~ 11)。 1 4
getUTCFullYear() 根据世界时从 Date 对象返回四位数的年份。 1 4
getUTCHours() 根据世界时返回 Date 对象的小时 (0 ~ 23)。 1 4
getUTCMinutes() 根据世界时返回 Date 对象的分钟 (0 ~ 59)。 1 4
getUTCSeconds() 根据世界时返回 Date 对象的秒钟 (0 ~ 59)。 1 4
getUTCMilliseconds() 根据世界时返回 Date 对象的毫秒(0 ~ 999)。 1 4
parse() 返回1970年1月1日午夜到指定日期(字符串)的毫秒数。 1 3
setDate() 设置 Date 对象中月的某一天 (1 ~ 31)。 1 3
setMonth() 设置 Date 对象中月份 (0 ~ 11)。 1 3
setFullYear() 设置 Date 对象中的年份(四位数字)。 1 4
setYear() 请使用 setFullYear() 方法代替。 1 3
setHours() 设置 Date 对象中的小时 (0 ~ 23)。 1 3
setMinutes() 设置 Date 对象中的分钟 (0 ~ 59)。 1 3
setSeconds() 设置 Date 对象中的秒钟 (0 ~ 59)。 1 3
setMilliseconds() 设置 Date 对象中的毫秒 (0 ~ 999)。 1 4
setTime() 以毫秒设置 Date 对象。 1 3
setUTCDate() 根据世界时设置 Date 对象中月份的一天 (1 ~ 31)。 1 4
setUTCMonth() 根据世界时设置 Date 对象中的月份 (0 ~ 11)。 1 4
setUTCFullYear() 根据世界时设置 Date 对象中的年份(四位