PHP function
function getMonthDayNum($month, $year) {
$month = (int)$month;
$year = (int)$year;
$days = 30;
switch ($month) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
$days = 31;
break;
case 2:
if (($year % 100 === 0 && $year % 400 === 0) || $year % 4 === 0) {
$days = 29;
} else {
$days = 28;
}
break;
}
return $days;
}
Javascript function
function getMonthDayNum(month, year) {
month = Number(month);
year = Number(year);
days = 30;
switch (month) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
days = 31;
break;
case 2:
if ((year % 100 === 0 && year % 400 === 0) || year % 4 === 0) {
days = 29;
} else {
days = 28;
}
break;
}
return days;
}
0 comments:
Post a Comment