Input Time step attribute

Definition and usage

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

The HTML step attribute specifies the valid numerical interval of seconds or milliseconds in the time field (not applicable to hours or minutes).

Example: If step="2", valid numbers can be 0, 2, 4, and so on.

Tip:The step attribute is usually used with max and min Used together with attributes to create a series of valid values.

See also:

HTML Reference Manual:HTML <input> step Attribute

Example

Example 1

Change the valid numerical interval of seconds in the time field:

document.getElementById("myTime").step = "10";

Try it yourself

Example 2

Change the valid numerical interval in the time field to milliseconds:

document.getElementById("myTime").step = ".050";

Try it yourself

Example 3

Get the valid numerical interval of seconds in the time field:

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

Try it yourself

Syntax

Return the step attribute:

timeObject.step

Set the step attribute:

timeObject.step = number

Attribute value

Value Description
number

A valid numerical interval in the specified time field.

For seconds:

Using a number that will eventually reach "60". For example: "1", "2", "10", "30" and so on.

For milliseconds:

Starting from "." and using a number that will eventually reach "1000". For example: ".010", ".050", ".20" and so on.

Technical details

Return value: The number, representing a valid time interval in seconds or milliseconds.

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

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.