function DateTimeNormalizer::normalize
Same name in other branches
- 9 core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::normalize()
- 8.9.x core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::normalize()
- 11.x core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::normalize()
1 method overrides DateTimeNormalizer::normalize()
- DateTimeIso8601Normalizer::normalize in core/
modules/ serialization/ src/ Normalizer/ DateTimeIso8601Normalizer.php
File
-
core/
modules/ serialization/ src/ Normalizer/ DateTimeNormalizer.php, line 52
Class
- DateTimeNormalizer
- Converts values for datetime objects to RFC3339 and from common formats.
Namespace
Drupal\serialization\NormalizerCode
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->setTimezone($this->getNormalizationTimezone())
->format(\DateTime::RFC3339);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.