‪TYPO3CMS  ‪main
TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper:

Public Member Functions

 initializeArguments ()
 
 resolveContentArgumentName ()
 

Static Public Member Functions

static renderStatic (array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 

Protected Attributes

bool $escapeChildren = false
 

Static Private Member Functions

static resolveLocale (RenderingContextInterface $renderingContext)
 

Detailed Description

Formats an object implementing :php:\DateTimeInterface.

Possible date/time formats can be found in the PHP documentation: https://www.php.net/manual/datetime.format.php

Examples

Defaults

::

<f:format.date>{dateObject}</f:format.date>

1980-12-13 Depending on the current date.

Custom date format

::

<f:format.date format="H:i">{dateObject}</f:format.date>

01:23 Depending on the current time.

Relative date with given time

::

<f:format.date format="Y" base="{dateObject}">-1 year</f:format.date>

2016 Assuming dateObject is in 2017.

strtotime string

::

<f:format.date format="d.m.Y - H:i:s">+1 week 2 days 4 hours 2 seconds</f:format.date>

13.12.1980 - 21:03:42 Depending on the current time, see https://www.php.net/manual/function.strtotime.php.

Localized dates using strftime date format

::

<f:format.date format="%d. %B %Y">{dateObject}</f:format.date>

13. Dezember 1980 Depending on the current date and defined locale. In the example you see the 1980-12-13 in a german locale.

Localized dates using ICU-based date and time formatting

::

<f:format.date pattern="dd. MMMM yyyy" locale="de-DE">{dateObject}</f:format.date>

13. Dezember 1980 Depending on the current date. In the example you see the 1980-12-13 in a german locale.

Localized dates using default formatting patterns

::

<f:format.date pattern="FULL" locale="fr-FR">{dateObject}</f:format.date>

jeudi 9 mars 2023 à 21:40:49 temps universel coordonné Depending on the current date and operating system setting. In the example you see the 2023-03-09 in a french locale.

Inline notation

::

{f:format.date(date: dateObject)}

1980-12-13 Depending on the value of {dateObject}.

Inline notation (2nd variant)

::

{dateObject -> f:format.date()}

1980-12-13 Depending on the value of {dateObject}.

Definition at line 133 of file DateViewHelper.php.

Member Function Documentation

◆ initializeArguments()

TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper::initializeArguments ( )

Definition at line 142 of file DateViewHelper.php.

◆ renderStatic()

static TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper::renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
RenderingContextInterface  $renderingContext 
)
static

◆ resolveContentArgumentName()

TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper::resolveContentArgumentName ( )

Explicitly set argument name to be used as content.

Definition at line 206 of file DateViewHelper.php.

◆ resolveLocale()

static TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper::resolveLocale ( RenderingContextInterface  $renderingContext)
staticprivate

Member Data Documentation

◆ $escapeChildren

bool TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper::$escapeChildren = false
protected

Needed as child node's output can return a DateTime object which can't be escaped

Definition at line 140 of file DateViewHelper.php.