使用js在网页上显示时间
<html> <script> function getDate(){ var d,s,t; d = new Date(); s = d.getFullYear().toString()+"-"; t = d.getMonth()+1; s += (t>9?"":"0")+t+"-"; t = d.getDate(); s += (t>9?"":"0")+t+" " t = d.getHours(); s += (t>9?"":"0")+t+":"; t = d.getMinutes(); s += (t>9?"":"0")+t+":"; t = d.getSeconds(); s += (t>9?"":"0")+t; return s; } function showDate(){ var i = getDate(); document.all.now.innerHTML = i; } setInterval("showDate()", 1000); </script> <body> <div id="now"></div> </body> </html>