/** * 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 * * Dates::months(); * // aray(1 => 1, 2 => 2, 3 => 3, ..., 12 => 12) * * But you can customise this by passing in either Dates::MONTHS_LONG * * Dates::months(Dates::MONTHS_LONG); * // array(1 => 'January', 2 => 'February', ..., 12 => 'December') * * Or Dates::MONTHS_SHORT * * Dates::months(Dates::MONTHS_SHORT); * // array(1 => 'Jan', 2 => 'Feb', ..., 12 => 'Dec') * * @uses Dates::hours * @param string $format The format to use for months * @return array An array of months based on the specified format */ public static function months($format = NULL) { $months = array(); if ($format === Dates::MONTHS_LONG or $format === Dates::MONTHS_SHORT) { for ($i = 1; $i <= 12; ++$i) { $months[$i] = strftime($format, mktime(0, 0, 0, $i, 1)); } } else { $months = Dates::hours(); } return $months; }