Option 1: If you have a default time format for your application, it text_fieldwill use it. For example, you might have config/initializers/time_formats.rbone containing the following:
Time::DATE_FORMATS[:default] = '%m/%d/%Y %I:%M %p'
Option 2: You can override text_field valueusing strftimedirectly. For example:
<%- scheduled_at_string = form.object.scheduled_at && form.object.scheduled_at.strftime("%m/%d/%Y") -%>
<%= form.text_field :scheduled_at, :value => scheduled_at_string %>
(You might want to clean it with an assistant.)
source
share