[英]Rails: Changing date format displayed in date_field
I am working on a rails application and have changed the date format displayed across my app to dd.mm.yyyy
using the following code in a file in the config/initializers
directory: 我正在使用Rails应用程序,并且已在config/initializers
目录中的文件中使用以下代码将整个应用程序上显示的日期格式更改为dd.mm.yyyy
:
Date::DATE_FORMATS[:default]="%d.%m.%Y"
Time::DATE_FORMATS[:default]="%d.%m.%Y %H:%M"
However, in my forms where I am using the f.date_field
tags, the date display is shown as mm/dd/yyyy
. 但是,在使用f.date_field
标签的表单中,日期显示为mm/dd/yyyy
。 How can I change the format used there? 如何更改那里使用的格式?
尝试这个
f.date_field :some_name, value: @some_time.strftime('%d.%m.%Y')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.