Rails jQuery Mobile将字符串转换为时间(Rails jQuery Mobile convert string to time)

编程入门 行业动态 更新时间:2024-10-21 05:59:20
Rails jQuery Mobile将字符串转换为时间(Rails jQuery Mobile convert string to time)

我有Rails 4.0.0时间格式字段用于开始时间和结束时间。 我想使用jQuery Mobile DateBox格式化时间,如'02:41 AM'。 如何将此字符串转换为Rails中的时间字段。 我的数据库是Postgresql。

migratiuon:

t.time :start_time, :null => false t.time :finish_time, :null => false

I have Rails 4.0.0 time format fields for start time and finish time. I want to use the jQuery Mobile DateBox which formats the time like '02:41 AM'. How can I convert this string to a time field in Rails. My database is Postgresql.

migratiuon:

t.time :start_time, :null => false t.time :finish_time, :null => false

最满意答案

我决定忘记jQuery时间选择器,因为普通的Rails time_selector看起来很不错。 我遇到的一个问题是它输出两个选择选项字段,它们之间带有冒号(:)。 此冒号阻止data-type =“horizo​​ntal”显示内联。 解决方案如下。 此外,省略时间字段上的ignore_date会导致多参数超出范围错误。

<div> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>Start Time</legend> <%= f.time_select :start_time, time_separator: "", ignore_date: true, ampm: true %> </fieldset> </div>

I decided to forget about the jQuery time picker as the plain Rails time_selector looks pretty good. One issue I had with it was that it outputs two select options fields with a colon (:) in between them. This colon prevented data-type="horizontal" from displaying inline. The solution is as below. Furthermore, omitting ignore_date on a time field results in a Multiparameter out of range error.

<div> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>Start Time</legend> <%= f.time_select :start_time, time_separator: "", ignore_date: true, ampm: true %> </fieldset> </div>

更多推荐

本文发布于:2023-08-06 17:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1452833.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   转换为   时间   Rails   Mobile

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!