You are here

public function TimestampNormalizer::normalize in JSON:API 8.2

Overrides DateTimeNormalizer::normalize

File

src/ForwardCompatibility/Normalizer/TimestampNormalizer.php, line 39

Class

TimestampNormalizer
Converts values for the Timestamp data type to and from common formats.

Namespace

Drupal\jsonapi\ForwardCompatibility\Normalizer

Code

public function normalize($datetime, $format = NULL, array $context = []) {
  return DrupalDateTime::createFromTimestamp($datetime
    ->getValue())
    ->setTimezone($this
    ->getNormalizationTimezone())
    ->format(\DateTime::RFC3339);
}