public static function DateHelper::monthNames in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::monthNames()
- 9 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 81
Class
- DateHelper
- Defines Gregorian Calendar date values.
Namespace
Drupal\Core\DatetimeCode
public static function monthNames($required = FALSE) {
// Force the key to use the correct month value, rather than
// starting with zero.
$monthnames = [
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 + $monthnames : $monthnames;
}