// JavaScript Document window.onload = function(){ var oDateTarget = document.getElementById("txt"); var Day = new Date(); var weeks = ["日","一","二","三","四","五","六"]; oDateTarget.innerHTML = "日期:" + Day.getFullYear() + "年" + toDouble(parseInt(Day.getMonth() + 1)) + "月" + toDouble(Day.getDate()) + "日" + "星期" + weeks[Day.getDay()] + toDouble(Day.getHours()) + ":" + toDouble(Day.getMinutes()) + ":" + toDouble(Day.getSeconds()); var timeRefresh = null; timeRefresh = setInterval(function(){ var oDate = new Date(); oDateTarget.innerHTML = "日期:" + oDate.getFullYear() + "-" + toDouble(parseInt(oDate.getMonth() + 1)) + "-" + toDouble(oDate.getDate()) + " " + "星期" + weeks[oDate.getDay()] +" " + toDouble(oDate.getHours()) + ":" + toDouble(oDate.getMinutes()) + ":" + toDouble(oDate.getSeconds()); },1000); function toDouble(obj){ if(parseInt(obj) < 10){ return "0" + obj; }else{ return obj; } } };