Rails not picking up custom date & time formats in en.yml

ぐ巨炮叔叔 提交于 2019-12-05 22:31:11

You need to use the I18n.l method as follows:

1.9.3p194 :001 > I18n.l Time.now.to_date, :format => :long_dateweek
 => "Wednesday, August 22, 2012" 
1.9.3p194 :002 > I18n.l Time.now, :format => :very_short
 => "23:03"

You can also use the l helper method in your views. Look at this rails guide for more information.

@alexsanford1 has the right answer. I modified mine below to work in the view.

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