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