public function serializeDateTime(VisitorInterface $visitor, \DateTime $date, Type $type, Context $context) { $format = $this->getFormat($type); if ('U' === $format) { return $visitor->visitInteger($date->getTimestamp(), $type, $context); } return $this->serialize($visitor, $date->format($this->getFormat($type)), $type, $context); }