DateHelper::monthNames

public static DateHelper::monthNames($required = FALSE)

Returns a translated array of month names.

Parameters

bool $required: (optional) If FALSE, the returned array will include a blank value. Defaults to FALSE.

Return value

array An array of month names.

File

core/lib/Drupal/Core/Datetime/DateHelper.php, line 81

Class

DateHelper
Defines Gregorian Calendar date values.

Namespace

Drupal\Core\Datetime

Code

public static function monthNames($required = FALSE) {
  // Force the key to use the correct month value, rather than
  // starting with zero.
  $monthnames = array(
    1 => t('January', array(), array('context' => 'Long month name')),
    2 => t('February', array(), array('context' => 'Long month name')),
    3 => t('March', array(), array('context' => 'Long month name')),
    4 => t('April', array(), array('context' => 'Long month name')),
    5 => t('May', array(), array('context' => 'Long month name')),
    6 => t('June', array(), array('context' => 'Long month name')),
    7 => t('July', array(), array('context' => 'Long month name')),
    8 => t('August', array(), array('context' => 'Long month name')),
    9 => t('September', array(), array('context' => 'Long month name')),
    10 => t('October', array(), array('context' => 'Long month name')),
    11 => t('November', array(), array('context' => 'Long month name')),
    12 => t('December', array(), array('context' => 'Long month name')),
  );
  $none = array('' => '');
  return !$required ? $none + $monthnames : $monthnames;
}
doc_Drupal
2016-10-29 09:00:50
Comments
Leave a Comment

Please login to continue.