Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DateHelper.php

function 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.
    $month_names = [
        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 + $month_names : $month_names;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal