当前位置: 代码迷 >> JavaScript >> javascript钟表
  详细解决方案

javascript钟表

热度:318   发布时间:2012-11-09 10:18:48.0
javascript时钟
function showDate() { 
var dt; 
dt = new Date(); 
var y,m,d; 
y = dt.getYear(); 
m = dt.getMonth()+1; 
d = dt.getDay(); 

var h,mi,s; 
h = dt.getHours(); 
mi = dt.getMinutes(); 
if(mi<10) 
  mi = "0"+mi; 
s = dt.getSeconds(); 
if(s<10) 
 s = "0"+s; 

var today; 
today = y + "年" + m + "月" + d + "日" + h + ":" + mi + ":" + s; 
document.getElementById("time(你所获得的Id)").innerText = today; 
setTimeout("showDate()",1000); 

} 
  相关解决方案