5

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?

Mohit Jain
  • 43,139
  • 57
  • 169
  • 274
  • `ampm: true` displays the time in am/pm format like `12pm:10`. It doesn't add an extra dropdown. So instead of this you want a dropdown with just the hours and an extra dropdown with just am/pm? – Arjan Apr 16 '13 at 12:18
  • @Arjan yes a 12 hour clock + am/pm as dropdown.. – Mohit Jain Apr 16 '13 at 14:49
  • You will just need to write your own time select helper to do this as rails doesn't currently have support in its helpers to display that format with the extra dropdown for am/pm – Donavan White May 01 '13 at 16:18
  • ampm: true and how to get the output from this! – nourza Jul 07 '19 at 19:01

1 Answers1

2

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/

jbearden
  • 1,869
  • 2
  • 19
  • 23