Javascript examples for Date:setDate
Set the day of the month to be the last day of the previous month:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//ww w .j a va 2s . co m var d = new Date(); d.setDate(0); document.getElementById("demo").innerHTML = d; } </script> </body> </html>