Open In App

HTML | DOM Input DatetimeLocal stepUp() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The Input DatetimeLocal stepUp() method in HTML DOM is used to increment the value of the Local datetime field by a specified number. The Input DatetimeLocal stepUp() method can only be used on the value Minutes. Years, months, days, hours, seconds or milliseconds are not affected by the stepUp() method.

Syntax:

datetimelocalObject.stepUp( number )

Parameters: This method accepts single parameter number which is used to specify the amount of minutes the local datetime field should increase. when we exclude number from datetimelocalObject.stepUp(number) and leave it as datetimelocalObject.stepUp() then by default number of minutes incremented by 1.

Below program illustrates the DatetimeLocal stepUp property in HTML DOM:

Example: This example use stepUp() method to increment the value of minutes by 2.




<!DOCTYPE html>
<html>
      
<head
    <title>
        Input DatetimeLocal stepUp() Method
    </title
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;">
        GeeksforGeeks
    </h1
      
    <h2 style="font-family: Impact;"
        Input DatetimeLocal stepUp() Method
    </h2>
      
    <input type="datetime-local" id="test_DatetimeLocal">
      
    <p>
        To increase the value of the datetimeLocal field
        by 2minutes, double click the "Update" button.
    </p>
      
    <button ondblclick="My_DatetimeLocal()">
        Update
    </button>
      
    <!-- Script to use stepUp() method -->
    <script>
        function My_DatetimeLocal() {
            document.getElementById("test_DatetimeLocal").stepUp(2);
        }
    </script>
</body>
  
</html>                    


Output:
Before clicking on the button:

After clicking on the button:

Supported Browsers: The browser supported by Input DatetimeLocal stepUp() method are listed below:

  • Apple Safari
  • Internet Explorer 12.0
  • Google Chrome
  • Opera


Last Updated : 17 Jan, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads