JavaScript 参考手册
JavaScript setUTCMonth() 方法
将月份设置为 4 (4月份)
源代码:
点击运行 »
<!DOCTYPE html> <html> <body> <p id="demo">Click the button to display the date after changing the month.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var d = new Date(); d.setUTCMonth(4); var x = document.getElementById("demo"); x.innerHTML = d; } </script> </body> </html>
运行结果:
点击运行 »