function showTime() { //时间 nowtime = new Date(); year = nowtime.getFullYear(); month = nowtime.getMonth() + 1; date = nowtime.getDate(); document.getElementById("mytime").innerHTML = year + "年" + month + "月" + date + "日" + nowtime.toLocaleTimeString(); } setInterval("showTime()", 1000);
<span id="mytime">__年_月_日</span>