DateFormatter::dateFormat

protected DateFormatter::dateFormat($format, $langcode)

Loads the given format pattern for the given langcode.

Parameters

string $format: The machine name of the date format.

string $langcode: The langcode of the language to use.

Return value

string|null The pattern for the date format in the given language for non-custom formats, NULL otherwise.

File

core/lib/Drupal/Core/Datetime/DateFormatter.php, line 323

Class

DateFormatter
Provides a service to handle various date related functionality.

Namespace

Drupal\Core\Datetime

Code

protected function dateFormat($format, $langcode) {
  if (!isset($this->dateFormats[$format][$langcode])) {
    $original_language = $this->languageManager->getConfigOverrideLanguage();
    $this->languageManager->setConfigOverrideLanguage(new Language(array('id' => $langcode)));
    $this->dateFormats[$format][$langcode] = $this->dateFormatStorage->load($format);
    $this->languageManager->setConfigOverrideLanguage($original_language);
  }
  return $this->dateFormats[$format][$langcode];
}
doc_Drupal
2016-10-29 09:00:45
Comments
Leave a Comment

Please login to continue.