public function render()
    {
        $date = $this->arguments['date'];
        $cldrFormat = $this->arguments['cldrFormat'];

        if ($date === null) {
            $date = $this->renderChildren();
            if ($date === null) {
                return '';
            }
        }
        if (!$date instanceof \DateTimeInterface) {
            try {
                $date = new \DateTime($date);
            } catch (\Exception $exception) {
                throw new ViewHelperException('"' . $date . '" could not be parsed by \DateTime constructor.', 1241722579, $exception);
            }
        }

        $useLocale = $this->getLocale();
        if ($useLocale !== null) {
            try {
                if ($cldrFormat !== null) {
                    $output = $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale);
                } else {
                    $output = $this->datetimeFormatter->format($date, $useLocale, [$this->arguments['localeFormatType'], $this->arguments['localeFormatLength']]);
                }
            } catch (I18nException $exception) {
                throw new ViewHelperException(sprintf('An error occurred while trying to format the given date/time: "%s"', $exception->getMessage()), 1342610987, $exception);
            }
        } else {
            $output = $date->format($this->arguments['format']);
        }

        return $output;
    }
public function render()
    {
        $date = $this->arguments['date'];
        $cldrFormat = $this->arguments['cldrFormat'];

        if ($date === null) {
            $date = $this->renderChildren();
            if ($date === null) {
                return '';
            }
        }
        if (!$date instanceof \DateTimeInterface) {
            try {
                $date = new \DateTime($date);
            } catch (\Exception $exception) {
                throw new ViewHelperException('"' . $date . '" could not be parsed by \DateTime constructor.', 1241722579, $exception);
            }
        }

        $useLocale = $this->getLocale();
        if ($useLocale !== null) {
            try {
                if ($cldrFormat !== null) {
                    $output = $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale);
                } else {
                    $output = $this->datetimeFormatter->format($date, $useLocale, [$this->arguments['localeFormatType'], $this->arguments['localeFormatLength']]);
                }
            } catch (I18nException $exception) {
                throw new ViewHelperException(sprintf('An error occurred while trying to format the given date/time: "%s"', $exception->getMessage()), 1342610987, $exception);
            }
        } else {
            $output = $date->format($this->arguments['format']);
        }

        return $output;
    }
public function render ( ) { $ date = $ this -> arguments [ 'date' ] ; $ cldrFormat = $ this -> arguments [ 'cldrFormat' ] ; if ( $ date === null ) { $ date = $ this -> renderChildren ( ) ; if ( $ date === null ) { return '' ; } } if ( ! $ date instanceof \ DateTimeInterface ) { try { $ date = new \ DateTime ( $ date ) ; } catch ( \ Exception $ exception ) { throw new ViewHelperException ( '"' . $ date . '" could not be parsed by \DateTime constructor.' , 1241722579 , $ exception ) ; } } $ useLocale = $ this -> getLocale ( ) ; if ( $ useLocale !== null ) { try { if ( $ cldrFormat !== null ) { $ output = $ this -> datetimeFormatter -> formatDateTimeWithCustomPattern ( $ date , $ cldrFormat , $ useLocale ) ; } else { $ output = $ this -> datetimeFormatter -> format ( $ date , $ useLocale , [ $ this -> arguments [ 'localeFormatType' ] , $ this -> arguments [ 'localeFormatLength' ] ] ) ; } } catch ( I18nException $ exception ) { throw new ViewHelperException ( sprintf ( 'An error occurred while trying to format the given date/time: "%s"' , $ exception -> getMessage ( ) ) , 1342610987 , $ exception ) ; } } else { $ output = $ date -> format ( $ this -> arguments [ 'format' ] ) ; } return $ output ; }
Render the supplied DateTime object as a formatted date.

@param mixed $date either a \DateTime object or a string that is accepted by \DateTime constructor
@param string $format Format String which is taken to format the Date/Time if none of the locale options are set.
@param string $localeFormatType Whether to format (according to locale set in $forceLocale) date, time or dateTime. Must be one of Neos\Flow\I18n\Cldr\Reader\DatesReader::FORMAT_TYPE_*'s constants.
@param string $localeFormatLength Format length if locale set in $forceLocale. Must be one of Neos\Flow\I18n\Cldr\Reader\DatesReader::FORMAT_LENGTH_*'s constants.
@param string $cldrFormat Format string in CLDR format (see http://cldr.unicode.org/translation/date-time)
@throws ViewHelperException
@return string Formatted date
@api
Render the supplied DateTime object as a formatted date .