2014-04-14 36 views

回答

4

您可以定义一个新的格式:

en: 
    date: # there is also a section for datetime and time 
    formats: 
     day_month_abbr: "%a, %d %b %Y" 

,并使用它像这样:

I18n.localize(Date.today, format: :day_month_abbr) 
# => "Mon, 14 Apr 2014" 

或者您可以覆盖默认格式:

en: 
    date: 
    formats: 
     default: "%a, %d %b %Y" 

然后你不需要给任何说法:

I18n.l(Date.today) #=> "Mon, 14 Apr 2014" 

所有可用于日期时间/时间/日期这里的通配符列表:http://apidock.com/ruby/DateTime/strftime

+0

你解决方案对我来说很完美。 – user1066183

相关问题