function DateTimeNormalizer::normalize
Same name in other branches
- 8.9.x core/modules/serialization/src/Normalizer/DateTimeNormalizer.php \Drupal\serialization\Normalizer\DateTimeNormalizer::normalize()
- 10 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 call to DateTimeNormalizer::normalize()
- DateTimeIso8601Normalizer::normalize in core/
modules/ serialization/ src/ Normalizer/ DateTimeIso8601Normalizer.php
1 method overrides DateTimeNormalizer::normalize()
- DateTimeIso8601Normalizer::normalize in core/
modules/ serialization/ src/ Normalizer/ DateTimeIso8601Normalizer.php
File
-
core/
modules/ serialization/ src/ Normalizer/ DateTimeNormalizer.php, line 57
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 = []) {
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.