src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/DateTimeToFormWidgetTransformer.php
public function transform($dateTime)
    {
        if ($dateTime === null || trim($dateTime) == '') {
            return '';
        }

        if (!$dateTime instanceof \DateTime) {
            throw new TransformationFailedException('Expected a \DateTime.');
        }

        $dateTime = clone $dateTime;
        if ($this->inputTimezone !== $this->outputTimezone) {
            try {
                $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone));
            } catch (\Exception $e) {
                throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
            }
        }

        // This is passed to the concrete5 DateTime widget, so the format
        // can be anything that can be parsed with the default PHP datetime
        // functions.
        return $dateTime->format('Y-m-d H:i:s');
    }
public function transform($dateTime)
    {
        if ($dateTime === null || trim($dateTime) == '') {
            return '';
        }

        if (!$dateTime instanceof \DateTime) {
            throw new TransformationFailedException('Expected a \DateTime.');
        }

        $dateTime = clone $dateTime;
        if ($this->inputTimezone !== $this->outputTimezone) {
            try {
                $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone));
            } catch (\Exception $e) {
                throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
            }
        }

        // This is passed to the concrete5 DateTime widget, so the format
        // can be anything that can be parsed with the default PHP datetime
        // functions.
        return $dateTime->format('Y-m-d H:i:s');
    }
public function transform ( $ dateTime ) { if ( $ dateTime === null || trim ( $ dateTime ) == '' ) { return '' ; } if ( ! $ dateTime instanceof \ DateTime ) { throw new TransformationFailedException ( 'Expected a \DateTime.' ) ; } $ dateTime = clone $ dateTime ; if ( $ this -> inputTimezone !== $ this -> outputTimezone ) { try { $ dateTime -> setTimezone ( new \ DateTimeZone ( $ this -> outputTimezone ) ) ; } catch ( \ Exception $ e ) { throw new TransformationFailedException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } // This is passed to the concrete5 DateTime widget, so the format // can be anything that can be parsed with the default PHP datetime // functions. return $ dateTime -> format ( 'Y-m-d H:i:s' ) ; }
Transforms a normalized date into a the concrete5 datetime widget format.

@param \DateTime $dateTime Normalized date.

@return string Widget format date.

@throws TransformationFailedException If the given value is not an
instance of \DateTime or if the
output timezone is not supported.
Transforms a normalized date into a the concrete5 datetime widget format .