function DateHelper::monthNamesAbbr

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::monthNamesAbbr()
  2. 10 core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::monthNamesAbbr()
  3. 11.x core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::monthNamesAbbr()

Constructs a translated array of month name abbreviations.

Parameters

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

Return value

array An array of month abbreviations.

File

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

Class

DateHelper
Defines Gregorian Calendar date values.

Namespace

Drupal\Core\Datetime

Code

public static function monthNamesAbbr($required = FALSE) {
    // Force the key to use the correct month value, rather than
    // starting with zero.
    $monthnames = [
        1 => t('Jan', [], [
            'context' => 'Abbreviated month name',
        ]),
        2 => t('Feb', [], [
            'context' => 'Abbreviated month name',
        ]),
        3 => t('Mar', [], [
            'context' => 'Abbreviated month name',
        ]),
        4 => t('Apr', [], [
            'context' => 'Abbreviated month name',
        ]),
        5 => t('May', [], [
            'context' => 'Abbreviated month name',
        ]),
        6 => t('Jun', [], [
            'context' => 'Abbreviated month name',
        ]),
        7 => t('Jul', [], [
            'context' => 'Abbreviated month name',
        ]),
        8 => t('Aug', [], [
            'context' => 'Abbreviated month name',
        ]),
        9 => t('Sep', [], [
            'context' => 'Abbreviated month name',
        ]),
        10 => t('Oct', [], [
            'context' => 'Abbreviated month name',
        ]),
        11 => t('Nov', [], [
            'context' => 'Abbreviated month name',
        ]),
        12 => t('Dec', [], [
            'context' => 'Abbreviated month name',
        ]),
    ];
    $none = [
        '' => '',
    ];
    return !$required ? $none + $monthnames : $monthnames;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.