代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CurrentTime Show</title> <script type="text/javascript"> function showTime () { CurrentTime = new Date(); year = CurrentTime.getFullYear(); month = CurrentTime.getMonth() + 1; date = CurrentTime.getDate(); document.getElementById("time").innerText = year + "年" + month + "月" + date + "日" + " " + CurrentTime.toLocaleTimeString(); } setInterval("showTime()", 1000); </script> </head> <body> <div id="time"> </div> </body> </html>