Symfony2: Localized date string in Twig template
Enable the intl twig extension in config.yml or services.yml file:
services:
twig.extension.intl:
class: Twig_Extensions_Extension_Intl
tags:
- { name: twig.extension }
In your Twig template, you can use pre-defined (http://twig.sensiolabs.org/doc/extensions/intl.html) or custom date formats (http://userguide.icu-project.org/formatparse/datetime) 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
Written by Andréia Bohner
Related protips
2 Responses
Thanks a lot!
over 1 year ago
·
Thank you very much!!!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Date
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#