public function transform($value)
    {
        if (null === $value) {
            return '';
        }

        if (!$value instanceof \DateTime) {
            throw new UnexpectedTypeException($value, '\DateTime');
        }

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

        return $value->format($this->format);
    }
public function transform($value)
    {
        if (null === $value) {
            return '';
        }

        if (!$value instanceof \DateTime) {
            throw new UnexpectedTypeException($value, '\DateTime');
        }

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

        return $value->format($this->format);
    }
public function transform ( $ value ) { if ( null === $ value ) { return '' ; } if ( ! $ value instanceof \ DateTime ) { throw new UnexpectedTypeException ( $ value , '\DateTime' ) ; } $ value = clone $ value ; try { $ value -> setTimezone ( new \ DateTimeZone ( $ this -> outputTimezone ) ) ; } catch ( \ Exception $ e ) { throw new TransformationFailedException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return $ value -> format ( $ this -> format ) ; }
Transforms a DateTime object into a date string with the configured format
and timezone

@param  DateTime $value A DateTime object

@return string A value as produced by PHP's date() function

@throws UnexpectedTypeException if the given value is not a \DateTime instance
@throws TransformationFailedException if the output timezone is not supported
Transforms a DateTime object into a date string with the configured format and timezone