简单教程
提交运行
代码编辑器:
<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.setUTCMonth(d.getUTCMonth(),0); var x = document.getElementById("demo"); x.innerHTML=d; } </script>
运行结果: