Javascript DOM HTML Input DatetimeLocal stepDown() Method

Introduction

Decrement the value of a datetime field by 10 minutes:

document.getElementById("myLocalDate").stepDown(10);

Click the button to decrement the value of the datetime field by 10 minutes.

View in separate window

<!DOCTYPE html>
<html>
<body>

Date: <input type="datetime-local" id="myLocalDate" value="2020-11-16T12:34:56">

<button onclick="myFunction()">Test</button>
<script>
function myFunction() {/*from  w  ww .java 2s.  c  om*/
  document.getElementById("myLocalDate").stepDown(10);
}
</script>

</body>
</html>

The stepDown() method decrements the value of the local datetime field by a specified number.

This method will only have an affect on minutes.

Parameter Description
numberRequired. Specifies the amount of minutes the datetime field should decrease.

If omitted, the minutes are decremented by "1"

Decrement the minutes by 1 (default):

document.getElementById("myLocalDate").stepDown();

Click the button to decrement the value of the datetime field by 1 minute.

View in separate window

<!DOCTYPE html>
<html>
<body>

Date: <input type="datetime-local" id="myLocalDate" value="2020-11-16T12:34:56">

<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//w ww .j  a  va  2s .c o  m
  document.getElementById("myLocalDate").stepDown();
}
</script>

</body>
</html>



PreviousNext

Related