You are here

public static function DateHelper::monthNames in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::monthNames()

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 84
Contains \Drupal\Core\Datetime\DateHelper.

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;
}