<! - Enter a year a certain day, that day is judgment day of the year
1. determine whether it is a leap year, exceeds the February;
2. The number of days per month consisting of an array does not contain a leap year;
3. If it is a leap year, and more than in February, plus one directly on the number of days;
-->
<script>
console.log(getDays(2019,5,11));
function getDays(year,month,day){
was arr = [31,28,31,30,31,30,31,31,30,31,30,31];
for(var i=0;i<month-1;i++){
day+=arr[i];
}
// determine whether it is a leap year, exceeds the February;
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;
}
</script>