获取当前时间
html 代码
当前时间<span id="clock"></span>
js 代码
<script> function changeClock() { var d = new Date(); document.getElementById("clock").innerHTML = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); } window.setInterval(changeClock, 1000); </script>