实时显示时间
<script>
function timer() {
setInterval(function() {
var date = new Date(),
y = date.toLocaleDateString().split("/"),
h = date.toLocaleTimeString().substr(2).split(":");
document.body.innerHTML = y[0] + "年-" + y[1] + "月-" + y[2] + "日 " + h[0] + "时:" + h[1] + "分" + h[2] + "秒";
}, 1000)
}
timer();
</script>