1.20.x date.inc | date_range_string($years) |
Converts a min and max year into a string like '-3:+1'.
Parameters
array $years: A numerically indexed array, containing a minimum and maximum year.
Return value
string: A min and max year string like '-3:+1'.
File
- includes/
date.inc, line 1492 - Date API functions and constants.
Code
function date_range_string($years) {
$this_year = date_format(date_now(), 'Y');
if ($years[0] < $this_year) {
$min = '-' . ($this_year - $years[0]);
}
else {
$min = '+' . ($years[0] - $this_year);
}
if ($years[1] < $this_year) {
$max = '-' . ($this_year - $years[1]);
}
else {
$max = '+' . ($years[1] - $this_year);
}
return $min . ':' . $max;
}