本文介绍了html5时间输入显示12小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 type = time 中使用html 5 input元素。问题在于它显示了 12小时的时间,但我希望它能在一天内显示在 24小时中。我怎样才能让它达到24小时?这里是我的输入字段
< input type =timename =timeplaceholder =hrs:minspattern =^([0-1] [0-9] | 2 [0-4]):([0-5] [0-9])(:[0-5] [0-9])? $class =输入时间要求>
DEMO
这是
解决方案
HTML5时间输入
这是最简单的日期/时间相关类型,允许用户选择 24小时制,否或PM 。
< input type =timename = 时间/>
此功能仍在草稿中。每个浏览器都有不同的显示方式。
- Opera(Presto Engine)显示了正确的方法。 - Chrome(Webkit Engine)在AM / PM中显示。
- Firefox(Gecko Engine)不显示任何内容,但验证通过。 - Edge在弹出式窗口中显示所有必需的值
< input type =timename =time/>
不是一个好主意!
I am using html 5 input element with type=time. The problem is it shows time with 12 hours but I want it to show it in 24 hours a day. How can I make it to 24 hours? Here is my input field
<input type="time" name="time" placeholder="hrs:mins" pattern="^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$" class="inputs time" required>
DEMO
Here is jsfiddle
解决方案
HTML5 Time Input
This one is the simplest of the date/time related types, allowing the user to select a time on a 24 hour clock, no AM or PM. The value returned is hours:minutes which will look something like 14:30.
<input type="time" name="time" />
This feature is still in draft. Each browser shows it differently.
- Opera (Presto Engine) shows it the right way.
- Chrome (Webkit Engine) shows it in AM/PM.
- Firefox (Gecko Engine) doesn't show anything, but validates.
- Edge shows all required values in a popover type window
<input type="time" name="time" />
Not a good idea to use!
这篇关于html5时间输入显示12小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-13 12:44