选择语言 :

 Core_Date::months

Number of months in a year. Typically used as a shortcut for generating a list that can be used in a form.

By default a mirrored array of $month_number => $month_number is returned

Date::months(); // aray(1 => 1, 2 => 2, 3 => 3, ..., 12 => 12)

But you can customise this by passing in either Date::MONTHS_LONG

Date::months(Date::MONTHS_LONG); // array(1 => 'January', 2 => 'February', ..., 12 => 'December')

Or Date::MONTHS_SHORT

Date::months(Date::MONTHS_SHORT); // array(1 => 'Jan', 2 => 'Feb', ..., 12 => 'Dec')

array Core_Date::months( [ string $format = null ] )
uses
Date::hours

参数列表

参数 类型 描述 默认值
$format string The format to use for months null
返回值
  • array An array of months based on the specified format
File: ./core/classes/date.class.php
public static function months($format = NULL)
{
    $months = array();

    if ( $format === DATE::MONTHS_LONG or $format === DATE::MONTHS_SHORT )
    {
        for( $i = 1; $i <= 12; ++ $i )
        {
            $months[$i] = strftime($format, mktime(0, 0, 0, $i, 1));
        }
    }
    else
    {
        $months = Date::hours();
    }

    return $months;
}