function DateHelper::ampm

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

Constructs an array of AM and PM options.

Parameters

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

Return value

array An array of AM and PM options.

File

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

Class

DateHelper
Defines Gregorian Calendar date values.

Namespace

Drupal\Core\Datetime

Code

public static function ampm($required = FALSE) {
    $none = [
        '' => '',
    ];
    $ampm = [
        'am' => t('am', [], [
            'context' => 'ampm',
        ]),
        'pm' => t('pm', [], [
            'context' => 'ampm',
        ]),
    ];
    return !$required ? $none + $ampm : $ampm;
}

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