选择语言 :

 Core_Date::years

Returns an array of years between a starting and ending year. By default, the the current year - 5 and current year + 5 will be used. Typically used as a shortcut for generating a list that can be used in a form.

$years = Date::years(2000, 2010); // 2000, 2001, ..., 2009, 2010

array Core_Date::years( [ integer $start = bool false , integer $end = bool false ] )

参数列表

参数 类型 描述 默认值
$start integer Starting year (default is current year - 5) bool false
$end integer Ending year (default is current year + 5) bool false
返回值
  • array
File: ./core/classes/date.class.php
public static function years($start = FALSE, $end = FALSE)
{
    // Default values
    $start = ($start === FALSE) ? (date('Y') - 5) : (int)$start;
    $end = ($end === FALSE) ? (date('Y') + 5) : (int)$end;

    $years = array();

    for( $i = $start; $i <= $end; $i ++ )
    {
        $years[$i] = (string)$i;
    }

    return $years;
}