W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>单击该按钮以根据 UTC 显示月份名称。</p> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var d = new Date(); var month = new Array(12); month[0] = "January"; month[1] = "February"; month[2] = "March"; month[3] = "April"; month[4] = "May"; month[5] = "June"; month[6] = "July"; month[7] = "August"; month[8] = "September"; month[9] = "October"; month[10] = "November"; month[11] = "December"; var n = month[d.getUTCMonth()]; document.getElementById("demo").innerHTML = n; } </script> <p><strong>Note:</strong> 0=January, 1=February, Etc.</p> </body> </html>