Sportica   Sportica

HTM页面获得本机时间

function settimes() 
{
var time = new Date();
hours = time.getHours();
mins = time.getMinutes();
secs = time.getSeconds();
years = time.getFullYear();
mons = (time.getMonth() + 1);
days = time.getDate();

mons = (mons < 10 ? '0' : '') + mons;
days = (days < 10 ? '0' : '') + days;

hours = (hours < 10 ? '0' : '') + hours;
mins = (mins < 10 ? '0' : '') + mins;
secs = (secs < 10 ? '0' : '') + secs;

document.getElementById("ClientTime").value = years + "-" + mons + "-" + days + " " + hours + ":" + mins + ":" + secs;
getSysTime(); //显示系统时间
setTimeout('settimes()', 999); //刷新
}
</script>
<body onload="settimes()">
<input type="text" id="ClientTime" readonly name="ClientTime" size="20" />
</body>
posted @ 2011-12-02 11:57  qingjoin  阅读(481)  评论(0编辑  收藏  举报
  Sportica