src/Graviton/SchemaBundle/Constraint/RecordOriginConstraint.php
private function convertDatetimeToUTC($object, $schema, \DateTimeZone $timezone)
    {
        foreach ($schema->properties as $field => $property) {
            if (isset($property->format) && $property->format == 'date-time' && isset($object->{$field})) {
                $dateTime = Rfc3339::createFromString($object->{$field});
                $dateTime->setTimezone($timezone);
                $object->{$field} = $dateTime->format(\DateTime::ISO8601);
            } elseif (isset($property->properties) && isset($object->{$field})) {
                $object->{$field} = $this->convertDatetimeToUTC($object->{$field}, $property, $timezone);
            }
        }
        return $object;
    }
private function convertDatetimeToUTC($object, $schema, \DateTimeZone $timezone)
    {
        foreach ($schema->properties as $field => $property) {
            if (isset($property->format) && $property->format == 'date-time' && isset($object->{$field})) {
                $dateTime = Rfc3339::createFromString($object->{$field});
                $dateTime->setTimezone($timezone);
                $object->{$field} = $dateTime->format(\DateTime::ISO8601);
            } elseif (isset($property->properties) && isset($object->{$field})) {
                $object->{$field} = $this->convertDatetimeToUTC($object->{$field}, $property, $timezone);
            }
        }
        return $object;
    }
private function convertDatetimeToUTC ( $ object , $ schema , \ DateTimeZone $ timezone ) { foreach ( $ schema -> properties as $ field => $ property ) { if ( isset ( $ property -> format ) && $ property -> format == 'date-time' && isset ( $ object -> { $ field } ) ) { $ dateTime = Rfc3339 :: createFromString ( $ object -> { $ field } ) ; $ dateTime -> setTimezone ( $ timezone ) ; $ object -> { $ field } = $ dateTime -> format ( \ DateTime :: ISO8601 ) ; } elseif ( isset ( $ property -> properties ) && isset ( $ object -> { $ field } ) ) { $ object -> { $ field } = $ this -> convertDatetimeToUTC ( $ object -> { $ field } , $ property , $ timezone ) ; } } return $ object ; }
Recursive convert date time to UTC
@param object        $object   Form data to be verified
@param object        $schema   Entity schema
@param \DateTimeZone $timezone to be converted to
@return object
Recursive convert date time to UTC