Force the use of a 24-hour time input type regardless of system locale
P粉189606269
2023-08-18 12:27:18
<p>I'm developing a small Angular application and I'm using the following HTML element when the user sets a start time: </p>
<p><br /></p>
<pre class="brush:html;toolbar:false;"><input type="time"></pre>
<p><br /></p>
<p>I noticed that this element works in 12-hour or 24-hour time depending on the user's system locale. Is there a way to always force a 24-hour clock, regardless of the system locale? </p>
<p>Alternatively, are there any JavaScript solutions available? </p>
No, and (according to MDN):
This is even less strict.
If your user interface requirements differ from those provided by the browser, then you must implement (or find) a custom input that meets those requirements, including validating the user input.