How to use setDate in JavaScript
In this article, I will explain use of setDate() method in JavaScript date object.
JavaScript setDate() method
setDate() method of date obeject sets the day of the month for a given date according to local time.
Syntax
Example
In the following example show to setDate() method sets the day of the month.
<!DOCTYPE html>
<html>
<body>
<h3 style="color:Teal ">JavaScript setDate() Method Example</h3>
<p id="demo">Click the button to display a specified date after changing the day of the month.</p>
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
function myFunction() {
var d = new Date("July 21, 1983 01:15:00");
d.setDate(15);
var x = document.getElementById("demo");
x.innerHTML = "Privious Date is : July 21, 1983 01:15:00 <br> After Set date is : " + d;
}
</script>
</body>
</html>
|
Output1

Output2

You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here