Javascript examples for Date:setMonth
Set the date to be the last day of last month:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w.j a va2s. c om var d = new Date(); d.setMonth(d.getMonth(), 0); document.getElementById("demo").innerHTML = d; } </script> </body> </html>