Input DatetimeLocal step attribute

Definition and usage

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

The HTML step attribute specifies the valid number intervals for seconds or milliseconds in the local date and time field (not applicable to days, months, years, hours, or minutes).

For 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-Eigenschaft

Instance

Example 1

Change the valid number interval of seconds in the local date field:

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

Try it yourself

Example 2

Change the valid number interval in the local date field to milliseconds:

document.getElementById("myLocalDate").step = ".020";

Try it yourself

Example 3

Get the valid number interval of seconds in the local date field:

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

Try it yourself

Syntax

Return step attribute:

datetimelocalObject.step

Set step attribute:

datetimelocalObject.step = number

Attribute value

Value Description
number

Define the valid number intervals in the local date and time field.

For seconds:

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

For milliseconds:

Starting with "." and using numbers that will eventually reach "1000". For example: ".010", ".050", ".20" and so on.

Technical details

Return value: Numbers, representing valid intervals 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
Unterstützt 10.0 Unterstützt Unterstützt Unterstützt

Hinweis:Hinweis: Das Element <input type="datetime-local"> zeigt in Firefox keine Datums- und Zeitfelder/Kalender an.