Set the month to 4 (May) and the day to the 20th: - Javascript Date

Javascript examples for Date:setMonth

Description

Set the month to 4 (May) and the day to the 20th:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from  w  ww.j  av a 2s . c  o  m
    var d = new Date();
    d.setMonth(4, 20);
    document.getElementById("demo").innerHTML = d;
}
</script>

</body>
</html>

Related Tutorials