Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony - Twig - Filter "localizeddate" doesn't work on DateTime

Tags:

twig

symfony

I'm using twig and when I apply the filter

{{tutoriel.dateCreation | localizeddate('medium', 'none') }} on my datetime, I have this error :

The filter "localizeddate" does not exist in Video2LearnAdministrationBundle:VisualisationFicheTutoriel:fiche_tutoriel.html.twig at line 167

Where I'm wrong ?

Thanks :)

like image 526
Zagloo Avatar asked Jun 24 '14 13:06

Zagloo


1 Answers

i use a new twig filter format_date() : https://twig.symfony.com/doc/2.x/filters/format_date.html

  1. Install: composer req twig/intl-extra
  2. Usages in twig:
created_at|format_date('full')
created_at|format_date('full', '', null, 'gregorian', 'fr')
created_at|format_date('none', 'MMMM Y', null, 'gregorian', 'fr')
like image 169
Breith Avatar answered Sep 17 '22 14:09

Breith