Search code examples
ruby-on-railsruby-on-rails-3timeruby-on-rails-3.2time-select

How to create a 12 hour (with AM/PM) time select element?


I am using rails 3.2.13. I want to show 12 hours of clock and am/pm also in dropdown. Seems lot of people talking about this but there is no inbuilt solution for the same.

time_select("post", "written_on", {:ampm => true})  # it gives me just two dropdowns. No dropdown for am/pm
f.time_select :written_on, :ampm => true  # same here. No third dropdown for am/pm

Any suggestions?


Solution

  • It's best to just delegate this to a good client side JS library. Below is what I personally use for my clients; it's awesome.

    http://amsul.ca/pickadate.js/