Javascript DOM HTML Input DatetimeLocal stepUp() Method

Introduction

Increment the value of a datetime field by 10 minutes:

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

Click the button to increment 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() {//  ww w  .j a  v  a  2  s.c  o  m
  document.getElementById("myLocalDate").stepUp(10);
}
</script>

</body>
</html>

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

This method will only have an affect on minutes.

Parameter Values

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

If omitted, the minutes are incremented by "1"

Increment the minutes by 1 (default):

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

Click the button to increment 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() {//from   w w w. j  av a  2s.  c om
  document.getElementById("myLocalDate").stepUp();
}
</script>

</body>
</html>



PreviousNext

Related