Edit on GitHub
Jump to docs navigation

Twig Components / Methods / localdate

Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?

localdate(format = null, locale = null, timezone = null) is a Twig filter to output a localized, readable version of a timestamp.

Parameter Description
format Optional The format used to display. If not provided, the default date_format from config/config.yaml will be used instead.
locale Optional The locale (language) in which to translate the date. If not provided, the default locale from config/services.yaml will be used instead.

To check all available date formats, please refer to the official php documentation https://www.php.net/manual/en/function.date.php

    {{ record.publishedAt|localdate }} {# Display published date with default format and locale #}
    {{ record.publishedAt|localdate(format='F j, Y H:i') }} {# Display published date with custom format and default locale #}
    {{ record.publishedAt|localdate(locale='nl') }} {# Display published date with default format and custom locale #}
    {{ record.publishedAt|localdate(format='F j, Y H:i', locale='nl') }} {# Display published date with default format and custom locale #}

    {{ "now"|localdate }} {# Display the current date and time #}


Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.