Javascript examples for Date:setUTCMonth
Set the date to be the last day of last month:setUTCMonth(d.getUTCMonth(), 0)
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . ja va 2s. c o m*/ var d = new Date(); d.setUTCMonth(d.getUTCMonth(), 0); document.getElementById("demo").innerHTML = d; } </script> </body> </html>