JavaScript获取指定某年某月总共有多少天

function isLeapYear(a){return a%400==0||a%4==0&&a%100!=0}
function calDays(a,b){return[null,31,null,31,30,31,30,31,31,30,31,30,31][b]||(isLeapYear(a)?29:28)};
//使用方法例子:alert(calDays(1988,2));

//上面是腾讯某网站写的JavaScript

//下面来自某国外网站(http://www.geekpedia.com/code76_Get-the-Last-Day-of-the-Month.html):
//LastDayOfMonth(year, month)
function LastDayOfMonth(a, b) {
 return (new Date(new Date(b + 1 + "/" + 1 + "/" + a) - 1)).getDate()
}
posted @ 2011-06-24 14:40  edielei  阅读(491)  评论(0编辑  收藏  举报