You are here

protected function StoreDateTimeFormatter::getTimezone in Commerce Core 8.2

Gets the timezone used for date formatting.

This is the timezone of the current store, with a fallback to the site timezone, in case the site doesn't have any stores yet.

Return value

string The timezone.

3 calls to StoreDateTimeFormatter::getTimezone()
StoreDateTimeFormatter::settingsForm in modules/store/src/Plugin/Field/FieldFormatter/StoreDateTimeFormatter.php
Returns a form to configure settings for the formatter.
StoreDateTimeFormatter::settingsSummary in modules/store/src/Plugin/Field/FieldFormatter/StoreDateTimeFormatter.php
Returns a short summary for the current formatter settings.
StoreDateTimeFormatter::viewElements in modules/store/src/Plugin/Field/FieldFormatter/StoreDateTimeFormatter.php
Builds a renderable array for a field value.

File

modules/store/src/Plugin/Field/FieldFormatter/StoreDateTimeFormatter.php, line 215

Class

StoreDateTimeFormatter
Plugin implementation of the 'commerce_store_datetime' formatter.

Namespace

Drupal\commerce_store\Plugin\Field\FieldFormatter

Code

protected function getTimezone() {
  $store = $this->currentStore
    ->getStore();
  if ($store) {
    $timezone = $store
      ->getTimezone();
  }
  else {
    $site_timezone = Store::getSiteTimezone();
    $timezone = reset($site_timezone);
  }
  return $timezone;
}