Input Time value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Time

Description

The value property sets or gets the value attribute of a time field.

Set the value property with the following Values

Value Description
hh:mm:ss.ms Sets a time for the time field.
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 30)
  • ss - seconds (e.g. 03)
  • ms - milliseconds (e.g 20)

Examples: "09:55:33.55", "22:15:35" or "16:00".

Return Value

A String, representing the time (with no timezone information) of the time field

The following code shows how to Set a time for a time field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Time: <input type="time" id="myTime" value="16:32:55">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from www  .  j  av a 2s .c o  m*/
    document.getElementById("myTime").value = '22:22:22';
    
}
</script>

</body>
</html>

Related Tutorials