執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Dates</h1> <h2>The getMonth() Method</h2> <p>Return the month of a date as a number from 0 to 11.</p> <p>To get the correct month number, you must add 1:</p> <p id="demo"></p> <script> const d = new Date(); document.getElementById("demo").innerHTML = d.getMonth() + 1; </script> </body> </html>