function date_calc_days_in_month in Date 6
Same name and namespace in other branches
- 5.2 date_php4/date_php4_calc.inc \date_calc_days_in_month()
- 6.2 date_php4/date_php4_calc.inc \date_calc_days_in_month()
Find the number of days in the given month.
Parameters
int $month: The month.
int $year: The 4 digit year. Do not add leading 0's for years prior to 1000.
Return value
int The number of days the month has.
5 calls to date_calc_days_in_month()
- date_calc_end_of_month_by_span in date_php4/
date_php4_calc.inc - Returns date of the last day of the month in the number of months from the given date.
- date_calc_get_calendar_month in date_php4/
date_php4_calc.inc - Return a set of arrays to construct a calendar month for the given date.
- date_calc_n_weekday_of_month in date_php4/
date_php4_calc.inc - Calculates the date of the Nth weekday of the month, such as the second Saturday of January 2000
- date_calc_weeks_in_month in date_php4/
date_php4_calc.inc - Returns the number of rows on a calendar month. Useful for determining the number of rows when displaying a typical month calendar.
- date_php4.inc in date_php4/
date_php4.inc
File
- date_php4/
date_php4_calc.inc, line 662
Code
function date_calc_days_in_month($month = 0, $year = 0) {
if (empty($year)) {
$year = date_calc_get_year();
}
if (empty($month)) {
$month = date_calc_get_month();
}
if ($year == 1582 && $month == 10) {
return 21;
// October 1582 only had 1st-4th and 15th-31st
}
if ($month == 2) {
if (date_is_leap_year($year)) {
return 29;
}
else {
return 28;
}
}
elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
return 30;
}
else {
return 31;
}
}