Symfony - Twig - 过滤“本地化日期"不适用于日期时间 [英] Symfony - Twig - Filter "localizeddate" doesn't work on DateTime

查看:20
本文介绍了Symfony - Twig - 过滤“本地化日期"不适用于日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用树枝,当我应用过滤器时

I'm using twig and when I apply the filter

{{tutoriel.dateCreation |在我的日期时间,localizeddate('medium', 'none') }},我有这个错误:

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

我哪里错了?

谢谢:)

推荐答案

我找到了解决方案.

您应该安装了 twig intl 扩展.如果没有,是否 composer 需要 twig/extensions

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

您可以像这样激活 config.yml 或 services.yml 文件中的服务:

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 }

这篇关于Symfony - Twig - 过滤“本地化日期"不适用于日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆