Last Updated: May 02, 2019
· andreia

Symfony2: Localized date string in Twig template

Enable the intl twig extension in config.yml or services.yml file:

        class: Twig_Extensions_Extension_Intl
            - { name: twig.extension }

In your Twig template, you can use pre-defined ( or custom date formats ( with the localizeddate:

{{ blog.created|localizeddate('none', 'none', 'pt_BR', null, "cccc, d MMMM Y 'às' hh:mm aaa")}}

The pattern "cccc, d MMMM Y 'às' hh:mm aaa" will show the date in this format:

domingo, 5 janeiro 2014 às 03:00 am

2 Responses
Add your response

Thanks a lot!

over 1 year ago ·

Thank you very much!!!

over 1 year ago ·