Home  >  Q&A  >  body text

Force the use of a 24-hour time input type regardless of system locale

<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>
P粉189606269P粉189606269428 days ago468

reply all(1)I'll reply

  • P粉343141633

    P粉3431416332023-08-19 11:25:56

    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.

    reply
    0
  • Cancelreply