奏鸣曲更改默认 format_date [英] Sonata change default format_date

查看:36
本文介绍了奏鸣曲更改默认 format_date的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 SonataIntlBundle 包.默认的 format_date 产生类似 day-number month-name year 的格式.

I have installed the SonataIntlBundlebundle. The default format_date results in a format like day-number month-name year.

{{ date_time_object |格式日期 }} =>'1 août 2011'来源

现在,我想将这个默认值更改为 dayNumber-monthNumber-yearNumber 对于有英文翻译 (en) 的人和 monthNumber-dayNumber-yearNumber 对于有英文翻译的人荷兰语翻译 (nl).我应该怎么做,他们是否有任何文档?

Now, I want to change this default to dayNumber-monthNumber-yearNumber for people with a english translation (en) and to monthNumber-dayNumber-yearNumberfor people with a dutch translation (nl). How should I do this and is their any documentation?

推荐答案

{{ date_time_object |format_date('MM-dd-yyyy', 'nl') }} 会起作用.如文档底部所定义.

{{ date_time_object | format_date('MM-dd-yyyy', 'nl') }} would work. As defined in the bottom of the documentation.

编辑

要在全球范围内执行此操作,您可以扩展 DateTimeHelper 类并将 sonata.intl.templating.helper.datetime.class 参数设置为 app/config/config.yml 中的该类.

To do it globally you can extend DateTimeHelper class and set sonata.intl.templating.helper.datetime.class parameter to that class in app/config/config.yml.

这篇关于奏鸣曲更改默认 format_date的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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