function date_days in Date 7
Same name and namespace in other branches
- 5.2 date_api.module \date_days()
- 6.2 date_api.module \date_days()
- 6 date_api.module \date_days()
- 7.3 date_api/date_api.module \date_days()
- 7.2 date_api/date_api.module \date_days()
An array of days.
Parameters
$required: If not required, returned array will include a blank value.
integer $month (optional):
integer $year (optional):
Return value
an array of days for the selected month.
1 call to date_days()
- date_parts_element in date_api/
date_api_elements.inc - Create form elements for one or more date parts.
File
- date_api/
date_api.module, line 906 - This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.
Code
function date_days($required = FALSE, $month = NULL, $year = NULL) {
// If we have a month and year, find the right last day of the month.
if (!empty($month) && !empty($year)) {
$date = new DateObject($year . '-' . $month . '-01 00:00:00', 'UTC');
$max = $date
->format('t');
}
// If there is no month and year given, default to 31.
if (empty($max)) {
$max = 31;
}
$none = array(
0 => '',
);
return !$required ? $none + drupal_map_assoc(range(1, $max)) : drupal_map_assoc(range(1, $max));
}