Twig localized DateTime String

20.01.2018 | Symfony | Twig

Twig Extensions Installieren

 

composer require twig/extensions

Aktivieren in services.yml

    twig.extension.intl:
        class: Twig_Extensions_Extension_Intl
        tags:
            - { name: twig.extension }

ODER in  config/twig_extensions.yaml (Symfony 4.1)

# Uncomment any lines below to activate that Twig extension
    Twig\Extensions\ArrayExtension: ~
    Twig\Extensions\DateExtension: ~
    Twig\Extensions\IntlExtension: ~
    Twig\Extensions\TextExtension: ~

Locale in services.yml oder config.yml

parameters:
    locale: 'de'

im template verwenden:

<div class="month">{{ event.start|localizeddate('medium', 'none', app.request.locale, null, 'LLL') }}</div>

Dokumentation

https://twig-extensions.readthedocs.io/en/latest/intl.html#localizeddate

Nützliche Timecodes:

http://userguide.icu-project.org/formatparse/datetime

 

 

Analyse

Entwurf

Development

Launch