getNormalizationTimezone example


  public function normalize($datetime$format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    assert($datetime instanceof DateTimeInterface);
    $drupal_date_time = $datetime->getDateTime();
    if ($drupal_date_time === NULL) {
      return $drupal_date_time;
    }
    return $drupal_date_time
      // Set an explicit timezone. Otherwise, timestamps may end up being       // normalized using the user's preferred timezone. Which would result in       // many variations and complex caching.       ->setTimezone($this->getNormalizationTimezone())
      ->format(\DateTime::RFC3339);
  }

  /** * Gets the timezone to be used during normalization. * * @see ::normalize * @see \Drupal\Core\Datetime\DrupalDateTime::prepareTimezone() * * @returns \DateTimeZone * The timezone to use. */
Home | Imprint | This part of the site doesn't use cookies.