输入类型时间的格式时间
这是我的输入:
<input
type="time"
className="start-time"
name="busi_start_time"
// value="Message"
/>
屏幕将显示为 hh:mm (12h)。如何将其格式化为 HH:mm (24 小时)?
this is my input:
<input
type="time"
className="start-time"
name="busi_start_time"
// value="Message"
/>
the screen will display as hh:mm (12h). How can I format it as HH:mm (24h)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法自定义 HTML 输入时间的显示格式,如您所见 在文档中:
HTML 输入的行为由浏览器定义,似乎所有浏览器都使用操作系统区域设置格式来选择要显示的显示格式展示给用户。因此,看到 12 小时还是 24 小时格式取决于您操作系统上的设置。
强制显示格式的一个潜在解决方案是使用库,但我想这超出了您的问题的范围。
It is not possible to customize the display format of the HTML input time as you can see in the documentation:
The behavior of the HTML input is defined by the browser and it seems that all browsers use the OS locale format to choose which display format to show to the user. So seeing a 12h or 24h format will depend on which is set on your OS.
A potential solution to force a display format is to use a library, but I guess that is outside of the scope of your question.