JS显示当前时间
<div id="clock"></div>
window.setInterval('showRealTime(clock)', 1000); function showRealTime(clock) { var d = new Date(); var year = d.getFullYear(); var month = d.getMonth() + 1; var date = d.getDate(); var days = new Array("日", "一", "二", "三", "四", "五", "六"); var day = d.getDay(); var hour = (d.getHours() < 10) ? ("0" + d.getHours()) : d.getHours(); var min = (d.getMinutes() < 10) ? ("0" + d.getMinutes()) : d.getMinutes(); var sec = (d.getSeconds() < 10) ? ("0" + d.getSeconds()) : d.getSeconds(); var now = year + "年" + month + "月" + date + "日 星期" + days[day] + " " + hour + ":" + min + ":" + sec; clock.innerHTML = now; }