Input Time value attribute

Definition and Usage

value Attribute sets or returns the value of the value attribute of the time field.

HTML value attribute specifies the time of the time field.

See also:

HTML Reference Manual:HTML <input> value Attribute

Instance

Example 1

Set the time of the time field:

document.getElementById("myTime").value = "18:45:30";

Try it yourself

Example 2

Get the time of the time field:

var x = document.getElementById("myTime").value;

Try it yourself

Example 3

An example showing the difference between the defaultValue and value attributes:

var x = document.getElementById("myTime");
var defaultVal = x.defaultValue;
var currentVal = x.value;

Try it yourself

Syntax

Return value attribute:

timeObject.value

Set value attribute:

timeObject.value = hh:mm:ss.ms

Attribute Value

Value Description
hh:mm:ss.ms

Time field of the specified time.

Component Description:

  • hh - Hours (for example, 22 indicates 10 PM)
  • mm - Minutes (for example, 36)
  • ss - Seconds (for example, 07)
  • ms - Milliseconds (for example, 50)

Example: "08:39:21.33", "22:36:07" or "15:00".

Technical Details

Return Value: A string value representing the time of the time field (without timezone information).

Browser Support

The numbers in the table indicate the first browser version to fully support this property.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="time"> element does not display as any time field in Firefox.