The HTML DOM Input DatetimeLocal step property determines the legal intervals for seconds or milliseconds.
Syntax
Following is the syntax −
- Returning number value
inputDatetimeLocalObject.step
- Setting step attribute to a number value
inputDatetimeLocalObject.step = number
Parameters
Parameter number values −
Value | Description |
---|---|
seconds | valid values constitute of those numbers that divide 60 perfectly (eg: 10,15,20) |
milliseconds | valid values start with “.” and divide 1000 perfectly (eg: .10, .20, .01) |
Example
Let us see an example of Input DatetimeLocal step property −
<!DOCTYPE html> <html> <head> <title>Input DatetimeLocal step</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>Datetime-Local-step</legend> <label for="datetimeLocalSelect">Local Date Time : <input type="datetime-local" id="datetimeLocalSelect" step="2"> </label> <input type="button" onclick="changeStep('10')" value="Step Seconds to 10"> <input type="button" onclick="changeStep('.10')" value="Step milliseconds to .10"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputDatetimeLocal = document.getElementById("datetimeLocalSelect"); function changeStep(myStep) { inputDatetimeLocal.step = myStep; if(inputDatetimeLocal.step.indexOf('.') === -1) divDisplay.textContent = 'Seconds step: '+inputDatetimeLocal.step; else divDisplay.textContent = 'Milli-seconds step: '+inputDatetimeLocal.step; } </script> </body> </html>
Output
This will produce the following output −
Clicking “Step Seconds to 10” button
Clicking “Step millseconds to .10” button −