c#

1:获取指定月份的天数
 int Days = DateTime.DaysInMonth(Year, Month);//Year指定的年份,Month指定的月份
 2:当前月份的天数
int   idate=System.DateTime.DaysInMonth(System.DateTime.Now.Year,System.DateTime.Now.Month); 

js

//方法一
获取指定月份的天数 [c#,js]
function DayNumOfMonth(Year,Month)
获取指定月份的天数 [c#,js]{
获取指定月份的天数 [c#,js]    
var d = new Date(Year,Month,0);
获取指定月份的天数 [c#,js]    
return d.getDate();
获取指定月份的天数 [c#,js]}
获取指定月份的天数 [c#,js]
//方法二
获取指定月份的天数 [c#,js]
function DayNumOfMonth(Year,Month)
获取指定月份的天数 [c#,js]{
获取指定月份的天数 [c#,js]    Month
--;
获取指定月份的天数 [c#,js]    
var d = new Date(Year,Month,1);
获取指定月份的天数 [c#,js]    d.setDate(d.getDate()
+32-d.getDate());
获取指定月份的天数 [c#,js]    
return (32-d.getDate());
获取指定月份的天数 [c#,js]}
获取指定月份的天数 [c#,js]
//方法三
获取指定月份的天数 [c#,js]
function DayNumOfMonth(Year,Month)
获取指定月份的天数 [c#,js]{
获取指定月份的天数 [c#,js]    
return 32-new Data(year,month,32).getData();
获取指定月份的天数 [c#,js]}

相关文章: