Formatting timestamps

后端 未结 6 1328
旧时难觅i
旧时难觅i 2021-02-12 12:30

How do you format Rails timestamps in a more human-readable format? If I simply print out created_at or updated_at in my view like this:



        
6条回答
  •  你的背包
    2021-02-12 12:33

    Take a look at the I18n functionality. It allows you to do the following in your views:

    <%= localize(scenario.created_at, :format => :long) %>

    where the formats are defined in your locales. More info

提交回复
热议问题