动态显示时间的客户端解决方案

    function showtime ()

 {

var now = new Date();

var year =now.getFullYear();
var month=now.getMonth();
var day=now.getDate();
var hours = now.getHours();

var minutes = now.getMinutes();

var seconds = now.getSeconds()

var timeValue=""+((hours>12) ? hours-12 :hours)

timeValue+=((minutes<10) ? ":0" : ":")+minutes

timeValue+=((seconds<10) ? ":0" : ":")+seconds

timeValue+=(hours >= 12) ? " PM.":" AM."

window.status =year+ timeValue;
document.getElementById('time').innerHTML="当前时间"+":"+ year+"年"+(month+1)+"月"+day+"日 "+timeValue;

timerID = setTimeout("showtime()",1000);
}

 

 

你可能感兴趣的:(Date,function)