Zagloo Zagloo - 1 month ago 7
Twig Question

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

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 :)

Answer

I found the solution.

You should have the twig intl extension installed. if not, do composer require twig/extensions

You may activate the services in config.yml or services.yml file like that:

services:
    twig.extension.intl:
        class: Twig_Extensions_Extension_Intl
        tags:
            - { name: twig.extension }