How can I make Rails 3 localize my date formats?

前端 未结 5 1338
终归单人心
终归单人心 2021-02-01 02:03

I am working on a Rails 3 project where there is place for date input within a form. The text field with the date uses a date picker so there is no concern about the date being

5条回答
  •  攒了一身酷
    2021-02-01 02:24

    When displaying a date, you can use I18n.l

    So you would do :

    I18n.l @entry.created_at
    

    And if you want to change it's format :

    I18n.l @entry.created_at, :format => :short
    

    The internationalization rails guide is documenting that.

提交回复
热议问题