console.log(getDays(2017,12,12)); function getDays(year,month,day){ var arr = [31,28,31,30,31,30,31,31,30,31,30,31]; for(var i=0;i<month-1;i++){ day += arr[i]; } if(month>2 && isRN(year)){ day+=1; } return day; } function isRN(year){ if(year%4===0 && year%100!==0 || year%400===0){ return true; } return false; }
原文:http://www.cnblogs.com/arealy/p/7833301.html