Is there a user-friendly time_select for Rails 3? The default time_select form helper gives you hours[00-23], minutes[00-59] and optionally seconds[00-59]. A dropdown list of hours 0-23 is pretty frustrating for those of us who aren't on military time. A user-friendly solution would display hours 1-12 and an extra am/pm dropdown list.
Is there an option or a separate plugin to handle this? I can't be the first person to want this, but I haven't found any solutions.
Thanks!
I don't know of a build in helper for exactly what you want. I suggest you build one, and share it! You likely don't want the first item in the dropdown to be 12am either, so that should be a config option.
Also, if 12am is 0 or 24 should be configurable too.
Here's a base using vanilla
select_tag
:It displays 12hour time to your user, and posts a 24 hour integer to your server.
Update
I needed one anyway, so I went ahead a wrote it.... In the view:
(Note the syntax is not
f.helper
, buthelper f, other_options
)In
app/helpers/am_pm_form_helper.rb
: