.. include:: ../../../Includes.txt f:format.date ============= This `f:format.date` viewhelper can produce date-time strings in a variety of formats. Properties ---------- date ~~~~ :aspect:`Type` `date` must be a `DateTime` object, or a string that can be converted to a `DateTime` object, or an integer Unix timestamp. :aspect:`Description` `'17.01.1979'` for example is accepted whereas `'17.01.79'` will not work. `date` can be a textual relative time description such as `'now'` or `'-1 year'` or `'next Thursday'`. If `date` is `null` the ViewHelper returns an empty string. As of TYPO3 CMS 7 `date` defaults to `now` if it is an empty string. If `date` is an integer it is considered to be a Unix timestamp that gets converted to a `DateTime` object with the PHP default timezone applied. The timezone is determined by the PHP function :php:`date_default_timezone_get()`. Recommended reading: `PHP: Getting the default timezone `__. :aspect:`Default value` NULL :aspect:`Mandatory` No format ~~~~~~ :aspect:`Type` String :aspect:`Description` `format` is a string that describes the desired form of the produced date-time string. If there is at least one % character in the format string, the rules of PHP's `strftime() `__ will be used. Otherwise the rules of PHP's `date() function `__ will be applied. :aspect:`Default value` The basic default is `'Y-m-d'` This can be overridden by setting :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'd-m-Y';` , for example. :aspect:`Mandatory` No base ~~~~ :aspect:`Type` `base` must be a `DateTime` object, or a string that can be converted to a `DateTime` object, or an integer Unix timestamp. :aspect:`Description` As of TYPO3 CMS 7 this ViewHelper uses `base` as the :php:`$now` parameter in PHP's `strtotime() function `__. In that case `base` constitutes the start time for calculations of textual relative time descriptions. :aspect:`Default value` The :php:`now()` equivalent. :aspect:`Mandatory` No .. highlight:: html Examples -------- Day Month Year ~~~~~~~~~~~~~~ Convert `dd.mm.yyyy`to `d/m/y`:: Now ~~~ :: Format Unix timestamps ~~~~~~~~~~~~~~~~~~~~~~ :: @1334439765 1334439765 Format and base defaults ~~~~~~~~~~~~~~~~~~~~~~~~ :: {dateObject} now Hours:minutes ~~~~~~~~~~~~~ :: {dateObject} A year before base time ~~~~~~~~~~~~~~~~~~~~~~~ :: -1 year -1 year -1 year -1 year -1 year A more complex textual relative time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: +1 week 2 days 4 hours 2 seconds Localized time using strftime syntax ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: {dateObject} now Inline notation ~~~~~~~~~~~~~~~ :: {f:format.date(date: dateObject)} {f:format.date(date: dateObject, format: "%d. %B %Y")} {f:format.date(date: "now", format: "%c")} More inline notation ~~~~~~~~~~~~~~~~~~~~ :: {dateObject -> f:format.date()} {dateObject -> f:format.date(format: 'Y-m-d H:i:s')}