public static function getFormat(\DateTime $date) { if ($date instanceof DateTime\Time || $date instanceof DateTime\Date || $date instanceof DateTime) { return $date->toString(); } else { return $date->getOffset() == 0 ? $date->format('Y-m-d\\TH:i:s') . 'Z' : $date->format(\DateTime::RFC3339); } }