Answer the question
In order to leave comments, you need to log in
Date format in rails?
Railroaders, help. By design, my user using the datepicker ( jquery-ui ) selects the date,
JS
jQuery ->
$('.datepicker').datepicker({
dateFormat: "dd.mm.y",
firstDay: 1
});
<p>
<%= f.label :start_date, "Начало" %><br>
<%= f.text_field :start_date, class: "datepicker" %>
</p>
Answer the question
In order to leave comments, you need to log in
You can rewrite the get method:
def start_date
self[:start_date].strftime("%d %b. %Y") if self[:start_date]
end
Helper or attr_accessor something like :start_date_human with strftime
In general, you can i18n.l
do it through, and in the en.yml config specify the default date and time output format such as you need. And as far as I remember, in the config/environment.rb
file you can specify:
my_format = { :default => '%d %b. %Y' }
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(my_format)
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(my_format)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question