function Appendzero (obj) { if (obj < 10) return "0" + obj; else return obj; } function getWeek () { var weeknum = new Date().getDay (); var week = ""; if (weeknum == 0) week = "星期日"; if (weeknum == 1) week = "星期一"; if (weeknum == 2) week = "星期二"; if (weeknum == 3) week = "星期三"; if (weeknum == 4) week = "星期四"; if (weeknum == 5) week = "星期五"; if (weeknum == 6) week = "星期六"; return week; } function getDate(){ var now = new Date (); var year = now.getFullYear ();//获取四位数年数 var month = now.getMonth () + 1; var date = now.getDate (); var s = year + "-" + Appendzero (month) + "-" + Appendzero (date) return s; } function getTime(){ var now = new Date (); var hour = now.getHours (); var minute = now.getMinutes (); var second = now.getSeconds (); var s = Appendzero (hour) + ":" + Appendzero (minute) + ":" + Appendzero (second); return s; } function getTime2(){ var now = new Date (); var hour = now.getHours (); var minute = now.getMinutes (); var s = Appendzero (hour) + ":" + Appendzero (minute) return s; } //设置动态时间 function setTime1(id){ document.getElementById("id").innerHTML = getTime2(); window.setTimeout("setTime("+id+")", 1000); } //设置动态时间 function setTime2(id){ document.getElementById("id").innerHTML = getTime1(); window.setTimeout("setTime("+id+")", 1000); }