开发者

display AM/PM format in time_select tag in rails

开发者 https://www.devze.com 2023-02-06 19:02 出处:网络
I am using <%= f.time_select :time_from ,:minute_step => 15 %> to display time select option with a step of 15 mins.

I am using

<%= f.time_select :time_from ,  :minute_step => 15 %>

to display time select option with a step of 15 mins.

Its showing 24hours clock. I want to show 12hour clock in display section (use开发者_运维百科r view) and 24hour clock in value section (for back ground processing.).


Here is 12 hour plugin for this.

http://code.google.com/p/rails-twelve-hour-time-plugin/


The plug-in is pretty old. For Rails 3, see https://gist.github.com/1340125. Rails 3.1 has a built-in option.


You can add am and pm to your time by putting this

<%= f.time_select :time,  {ampm: true},placeholder: "Pickup time"%>
0

精彩评论

暂无评论...
验证码 换一张
取 消