1 date.inc date_years($start = 0, $end = 0, $required = FALSE)

Constructs an array of years.

Parameters

int $start: The start year in the array.

int $end: The end year in the array.

bool $required: (optional) If FALSE, the returned array will include a blank value. Defaults to FALSE.

Return value

array: An array of years in the selected range.

File

core/includes/date.inc, line 258
Date API functions.

Code

function date_years($start = 0, $end = 0, $required = FALSE) {
  // Ensure $min and $max are valid values.
  if (empty($start)) {
    $start = intval(date('Y', REQUEST_TIME) - 3);
  }
  if (empty($end)) {
    $end = intval(date('Y', REQUEST_TIME) + 3);
  }
  $none = array(0 => '');
  return !$required ? $none + backdrop_map_assoc(range($start, $end)) : backdrop_map_assoc(range($start, $end));
}