javascript - 如何让 "am"或 "pm"指示符与 HTML5 时间输入元素一起显示?

标签 javascript jquery css html

当我添加 HTML5 时间输入元素时,它会显示:

__:__:__

好像是24小时制(军用/欧制)时制。我怎样才能让它附加一个“上午/下午”指示符(而且,正如我在 prior question 中指出的那样,我也不需要/不需要秒部分)?

最佳答案

可能重复:html5 time inputs shows 12 hoursHTML5 changing <input type="time"> to 24hrs. format? it is possible

似乎有些人坚持 24 小时,而另一些人坚持 12 小时的上午/下午。这是我发现的。对我来说,我一直停留在 24 小时模式,更改操作系统的日期格式对我不起作用(至少不是马上,可能是因为之前安装了 chrome)。所以我进入谷歌浏览器的设置 -> 显示高级设置 -> 语言 -> 语言和输入设置...然后我切换到英语(美国),重新启动 Chrome 和 Voilà,12 小时模式选择并能够选择 AM 或 PM .所以它的设计可能是为了让您不必担心它,它会根据用户的日期/时间格式首选项显示。我认为目前不可能强制按照此答案 Is there any way to change input type="date" format? 中的描述进行渲染。 .

The format displayed by the user interface control and accepted as user input. Browser vendors are encouraged to follow the user's preferences selection. For example, on Mac OS with the region "United States" selected in the Language & Text preferences pane, Chrome 20 uses the format "m/d/yy".

关于javascript - 如何让 "am"或 "pm"指示符与 HTML5 时间输入元素一起显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32184627/

相关文章:

javascript - 两个具有相同类名的 jquery slider ,但问题在于移动 slider (2)

javascript - 在不使用 .then 的情况下在类里面链式 promise

jquery - 使用 Ajax.BeginForm Asp.Net MVC 显示 jquery 验证消息

css - 背景视频过滤器隐藏覆盖 Div

通过css居中图像

html - 在 div 中定位文本

javascript - 使用混合移动应用程序防止逆向工程?

javascript - React Hooks react-hooks/exhaustive-deps eslint 规则似乎过于敏感

javascript - 按类查找 Angular 元素的最佳方法是什么?

javascript - 将 div 附加到 td