Changing the default date and time format in Rails 4

后端 未结 3 587
天涯浪人
天涯浪人 2020-12-03 01:22

I was looking for a way to change the default date format in Rails 4.

3条回答
  •  长情又很酷
    2020-12-03 01:43

    Add this

    # Date
    Date::DATE_FORMATS[:default] = "%d/%m/%Y" 
    
    # Time
    Time::DATE_FORMATS[:default] = "%d/%m/%Y %H:%M" 
    

    to config/initializers/date_time.rb

    Then restart the server.

提交回复
热议问题