使用Symfony 2本地化树枝中的日期 [英] Localize dates in twigs using Symfony 2

查看:60
本文介绍了使用Symfony 2本地化树枝中的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要格式化树枝中的日期,通常使用类似以下内容的

To format a date in twig you usually use something like:

{{ meeting.date|date("m/d/Y") }}

现在,我必须本地化该日期(美国月/日/年,荷兰日/月/年).在树枝中执行此操作的最佳实践是什么?我确实使用Symfony 2,一种解决方法是在控制器中进行翻译,但是我想在树枝中进行.

Now, I have to localize this date (US m/d/y, NL d/m/y). What would be the best practice to do this in the twig? I do use Symfony 2, a workaround would be to do the translation in the controller but i would like to do this in the twig.

推荐答案

在树枝模板中的用法:

{{ my_date | localizeddate('full', 'none', locale) }}

这篇关于使用Symfony 2本地化树枝中的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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