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

Breadcrumb

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

function 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 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.
    $month_names = [
        1 => t('January', [], [
            'context' => 'Long month name',
        ]),
        2 => t('February', [], [
            'context' => 'Long month name',
        ]),
        3 => t('March', [], [
            'context' => 'Long month name',
        ]),
        4 => t('April', [], [
            'context' => 'Long month name',
        ]),
        5 => t('May', [], [
            'context' => 'Long month name',
        ]),
        6 => t('June', [], [
            'context' => 'Long month name',
        ]),
        7 => t('July', [], [
            'context' => 'Long month name',
        ]),
        8 => t('August', [], [
            'context' => 'Long month name',
        ]),
        9 => t('September', [], [
            'context' => 'Long month name',
        ]),
        10 => t('October', [], [
            'context' => 'Long month name',
        ]),
        11 => t('November', [], [
            'context' => 'Long month name',
        ]),
        12 => t('December', [], [
            'context' => 'Long 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