<html>
<body>
<p id="demo">Click the button to display the date after setting the date to be the last day of last month.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var d = new Date();
d.setMonth(d.getMonth(),0);
var x = document.getElementById("demo");
x.innerHTML=d;
}
</script>
</body>
</html>