/**
- * determine how many days a certain month of a year
- * @return [Type][description]
- */
- function DaysInMonth ($year = ', $month = ') {
- if (empty ($year)) $year = Date (' Y ');
- if (empty ($month)) $month = Date (' m ');
- if (In_array ($month, Array (1, 3, 5, 7, 8, ' 01 ', ' 03 ', ' 05 ', ' 07 ', ' 08 ', 10, 12))) {
- $text = ' 31 '; // month-old
- }elseif ($month = = 2 | | $month = = ' 02 ') {
- if (($year% 400 = = 0) | | (($year% 4 = = 0) && ($year% 100!== 0))) { // to determine if a leap Year
- $text = ' 29 '; // Leap Year 2 Month
- }else {
- $text = ' 28 '; // Common year 2 Month
- }
- }else {
- $text = ' 30 '; // Month Small
- }
- return $text;
21.}
/**
- * determine how many days a certain month of a year
- * @return [Type][description]
- */
- function daysInmonth1 ($year = ', $month = ') {
- if (empty ($year)) $year = Date (' Y ');
- if (empty ($month)) $month = Date (' m ');
- $day = ' 01 ';
- // whether the detection date is legal
- if (!checkdate ($month, $day, $year)) return ' entered in the wrong time ';
- // gets the timestamp of the first day of the current month ( hours , minutes , seconds , months , Day , years )
- $timestamp = Mktime (0,0,0, $month, $day, $year);
- $result = date (' t ', $timestamp);
- return $result;
16.}
PHP determines how many days of the month