Javascript examples for Date:setDate
The setDate() method sets the day of the month to the date object.
Parameter | Description |
---|---|
day | Required. An integer representing the day of a month. |
Expected values are 1-31, but other values are allowed:
A Number, representing the number of milliseconds between the date object and midnight January 1 1970
The following code shows how to Set the day of the month:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w .j av a 2 s .c o m var d = new Date("July 21, 2020 01:15:00"); d.setDate(15); document.getElementById("demo").innerHTML = d; } </script> </body> </html>