function date_years in Date 6
Same name and namespace in other branches
- 5.2 date_api.module \date_years()
- 6.2 date_api.module \date_years()
- 7.3 date_api/date_api.module \date_years()
- 7 date_api/date_api.module \date_years()
- 7.2 date_api/date_api.module \date_years()
An array of years.
Parameters
int $min: the minimum year in the array
int $max: the maximum year in the array
$required: If not required, will include a blank value at the beginning of the array.
Return value
an array of years in the selected range
1 call to date_years()
- date_parts_element in ./
date_api_elements.inc - Create form elements for one or more date parts.
File
- ./
date_api.module, line 209 - 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_years($min = 0, $max = 0, $required = FALSE) {
// Have to be sure $min and $max are valid values;
if (empty($min)) {
$min = intval(date('Y', time()) - 3);
}
if (empty($max)) {
$max = intval(date('Y', time()) + 3);
}
$none = array(
0 => '',
);
return !$required ? $none + drupal_map_assoc(range($min, $max)) : drupal_map_assoc(range($min, $max));
}