just add twig extension to config.yml
services: twig.extension.intl: class: Twig_Extensions_Extension_Intl tags: - { name: twig.extension }
In your template branch Syntax: {{myDate | localizeddate ('sizeDate', 'sizeHour', 'locale'}} myDate: must be a DateTime object sizeDate: may be none / short / medium / long / full sizeHour: may be none / short / medium / long / full locale: optional By default, the session language will be used, but you can force one value of the locale
{{ myDate | localizeddate('full', 'none') }} ({{ myDate | localizeddate('none', 'short') }})
If you receive the error message ' Please install the extension' intl for full localization capabilities
install php5-intl package for example. on a Debian server the command will be: apt-get install php5-intl
Do not forget to clear the cache;)
Fabrice g
source share