Rails Time Select, reorder components

The default datetime form constructor rails provides the following form elements as selection fields ...

[YYYY] [MONTH] [DD] - [HH]:[MM] 

... after 24 hours.

I would like to introduce my users:

 [MON.] [DD] [YYYY] - [HH]:[MM] [AM/PM] 

How do you do this?

+4
source share
1 answer

datetime_select The helper has many different options. I never bothered to remember all of them, so I use this apidock page as a link (datetime_select and date_select have similar parameters).

In this case, you need to set the array :order :ampm to true, etc.

Edit: ok, I really bothered to write the hash option you need:

 date_select("question", "answered_at", :ampm => true, :order => [:month, :day, :year], :use_short_month => true) 
+4
source

Source: https://habr.com/ru/post/1380928/


All Articles