输入类型时间的格式时间

发布于 2025-01-15 06:31:28 字数 286 浏览 2 评论 0原文

这是我的输入:

                <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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╄→承喏 2025-01-22 06:31:28

无法自定义 HTML 输入时间的显示格式,如您所见 在文档中

[...] 根据系统区域设置使用 12 小时或 24 小时格式输入时间

HTML 输入的行为由浏览器定义,似乎所有浏览器都使用操作系统区域设置格式来选择要显示的显示格式展示给用户。因此,看到 12 小时还是 24 小时格式取决于您操作系统上的设置。

强制显示格式的一个潜在解决方案是使用库,但我想这超出了您的问题的范围。

It is not possible to customize the display format of the HTML input time as you can see in the documentation:

[...] uses a 12- or 24-hour format for inputting times, based on system locale

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文