function disptime() { var now = new Date(); var year = now.getFullYear(); var month = now.getMonth() + 1; var date = now.getDate(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); if (month >= 10) { month = month; } else { month = "0" + month; } if (date >= 10) { date = date; } else { date = "0" + date; } if (hours >= 10) { hours = hours; } else { hours = "0" + hours; } if (minutes >= 10) { minutes = minutes; } else { minutes = "0" + minutes; } if (seconds >= 10) { seconds = seconds; } else { seconds = "0" + seconds; } document.getElementById("outputtime").innerHTML = "今天是 " + year + "年" + month + "月" + date + "日" + " "; setTimeout("disptime ()", 1000); } disptime();