Sonata change default format_date

青春壹個敷衍的年華 提交于 2020-01-11 14:20:23

问题


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

{{ date_time_object | format_date }} => '1 août 2011'Source

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?


回答1:


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

Edit

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.



来源:https://stackoverflow.com/questions/10432652/sonata-change-default-format-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!