HTML <input type="time" />
element accepts a value that is in:
- 24-hour format with leading zeros, and;
- "
hh:mm
" and "hh:mm:ss
" format only.
Therefore, to set a default value on the <input type="time" />
element, you simply need to set the value
attribute to the correct format. For example, to set a default value of "3:45 pm", you would write it in 24-hour format, like so:
<input type="time" value="15:45" />
Similarly, the following would have a default value of "3:45 am and 25 seconds":
<input type="time" value="03:45:25" />
Please note that the visual representation of time picker may vary depending on the user's browser and/or OS.
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.