Javascript DOM HTML Input DatetimeLocal step Property set seconds

Introduction

Change the number intervals for seconds in a local date field:

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

Click button to change the step attribute of the local date field for seconds interval.

View in separate window

<!DOCTYPE html>
<html>
<body>

Date: <input type="datetime-local" id="myLocalDate" step="2">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {// w  ww . j  av  a 2 s.  c om
  document.getElementById("myLocalDate").step = "10";
  document.getElementById("demo").innerHTML = "The value of the step attribute was changed from '2' to '10'.";
}
</script>

</body>
</html>

The step property sets or gets the value of the step attribute of a local datetime field.

The step attribute sets the number intervals for seconds or milliseconds in a local datetime field.

For example: if step="2", the numbers could be 0, 2, 4, etc.

The step property accepts and returns a number value.

For seconds: Use numbers that will eventually reach "60".

Like: "1, "2", "10", "30", etc.

For milliseconds: start with "." and use numbers that eventually will reach "1000".

Like ".010", ".050", ".20", etc.

The step property returns a number representing the legal number intervals for seconds or milliseconds.




PreviousNext

Related