Transformer/DateParserTransformer.php
public function transform($value, array $options = [])
    {
        if (!$value || $value instanceof \DateTime) {
            return $value;
        }

        $date = \DateTime::createFromFormat($options['format'], $value);

        if (!$date) {
            throw new \UnexpectedValueException('Given value cannot be parsed into a date');
        }

        return $date;
    }
public function transform($value, array $options = [])
    {
        if (!$value || $value instanceof \DateTime) {
            return $value;
        }

        $date = \DateTime::createFromFormat($options['format'], $value);

        if (!$date) {
            throw new \UnexpectedValueException('Given value cannot be parsed into a date');
        }

        return $date;
    }
@param mixed $value
@param array $options

@return mixed|string