运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Dates</h1> <p>Add zeros and colons to display the universal time:</p> <p id="demo"></p> <script> function addZero(i) { if (i < 10) {i = "0" + i} return i; } const d = new Date(); let h = addZero(d.getUTCHours()); let m = addZero(d.getUTCMinutes()); let s = addZero(d.getUTCSeconds()); let time = h + ":" + m + ":" + s; document.getElementById("demo").innerHTML = time; </script> </body> </html>