function DateTimeNormalizer::getNormalizationTimezone

Same name in other branches
  1. 8.9.x core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::getNormalizationTimezone()
  2. 10 core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::getNormalizationTimezone()
  3. 11.x core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::getNormalizationTimezone()

Gets the timezone to be used during normalization.

@returns \DateTimeZone The timezone to use.

See also

::normalize

\Drupal\Core\Datetime\DrupalDateTime::prepareTimezone()

1 method overrides DateTimeNormalizer::getNormalizationTimezone()
TimestampNormalizer::getNormalizationTimezone in core/modules/serialization/src/Normalizer/TimestampNormalizer.php
Gets the timezone to be used during normalization.

File

core/modules/serialization/src/Normalizer/DateTimeNormalizer.php, line 80

Class

DateTimeNormalizer
Converts values for datetime objects to RFC3339 and from common formats.

Namespace

Drupal\serialization\Normalizer

Code

protected function getNormalizationTimezone() {
    $default_site_timezone = $this->systemDateConfig
        ->get('timezone.default');
    return new \DateTimeZone($default_site_timezone);
}

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