Formatting timestamps

后端 未结 6 1321
旧时难觅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:45

    Also

    <%= l scenario.created_at, :format => :sample) %>
    

    And in locales/en.yml(depending of language)

      en:
        time:
          formats:
            sample: '%d.%m.%Y'
    

    To learn more, see - http://guides.rubyonrails.org/i18n.html

提交回复
热议问题