时间为 Rails 3 选择 12 小时格式的表单助手? [英] Time select form helper with 12 hour format for Rails 3?

查看:59
本文介绍了时间为 Rails 3 选择 12 小时格式的表单助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails 3 有用户友好的 time_select 吗?默认的 time_select 表单助手为您提供小时 [00-23]、分钟 [00-59] 和可选的秒 [00-59].对于我们这些不在军事时间的人来说,0-23 小时的下拉列表非常令人沮丧.一个用户友好的解决方案会显示 1-12 小时和一个额外的 am/pm 下拉列表.

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.

谢谢!

推荐答案

您可以将 :ampm 选项设置为 true,这将显示时间为:12 PM, 01 AM .. 11 PM.

You can set :ampm option to true which will show the hours as: 12 PM, 01 AM .. 11 PM.

time_select 'game', 'game_time', {:ampm => true}

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_select

这篇关于时间为 Rails 3 选择 12 小时格式的表单助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆