获取某个月的最后一天或某个月的天数
时间:2021-07-01 10:21:17
帮助过:25人阅读
- //获取某个月的最后一天或某个月的天数
- function getMonthLastDay ( $month, $year )
- {
- switch ( $month )
- {
- case 4 :
- case 6 :
- case 9 :
- case 11 :
- $days = 30;
- break;
- case 2 :
- if ( $year % 4 == 0 )
- {
- if ( $year % 100 == 0 )
- {
- $days = $year % 400 == 0 ? 29 : 28;
- }
- else
- {
- $days = 29;
- }
- }
- else
- {
- $days = 28;
- }
- break;
- default :
- $days = 31;
- break;
- }
- return $days;
- }
|