I am displaying a DateTime object in twig like this:
<td>{{ transaction.getDate|date("F - d - Y") }}</td>
Now I want the month to be translatable,
For example April - 20 - 2012
should be displayed as: Avril - 20 - 2012
Can I do this? If so, how?
I am working on Symfony2.
or use the The Intl Extension :
{{ "now"|localizeddate('none', 'none', app.request.locale, "Europe/Paris", "cccc d MMMM Y") }}
Will give you something like :
jeudi 25 février 2016
To enable with symfony 2, add to composer :
composer require twig/extensions
And activate filters with service :
services:
twig.extension.intl:
class: Twig_Extensions_Extension_Intl
tags:
- { name: twig.extension }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With