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 ] )
参数列表
参数 类型 描述 默认值 $format
string
The format to use for months null
array
An array of months based on the specified formatpublic 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;
}