Rails not picking up custom date & time formats in en.yml
date-format, formatting, internationalization, ruby-on-rails, ruby-on-rails-3
Solution
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.
Problem
I'm not that familiar with I18N in Rails so bear with me. Trying to set a custom date & time format: ``` #config/locales/en.yml en: date: formats: long_dateweek: "%A, %B %d, %Y" time: formats: very_short: "%H:%M" ``` But when I try to use them I just get the default formats: ``` 1.9.3p194 :001 > Time.now.to_date.to_s(:long_dateweek) => "2012-08-22" 1.9.3p194 :002 > Time.now.to_time.to_s(:very_short) => "2012-08-22 16:12:47 -0700" ``` Tried restarting console (and even the server) to no avail... What'd I miss?