javascript簡單實現(xiàn)時鐘的例子
來源:易賢網(wǎng) 閱讀:974 次 日期:2016-06-24 10:39:53
溫馨提示:易賢網(wǎng)小編為您整理了“javascript簡單實現(xiàn)時鐘的例子”,方便廣大網(wǎng)友查閱!

javascript簡單實現(xiàn)時鐘的例子,具體實現(xiàn)

代碼如下:

<body onload=updatenowtime()>

<p id=nt></p>

<script>

/*一段時鐘小例子 write by yangxia 2013-05-23*/

var caltime = function (t) {

if (t < 10) t = 0 + t;

return t;

}

var updatenowtime = function () {

var date = new date();

var year = date.getfullyear();

var month = date.getmonth() + 1; //獲取當前月0 - 11

var day = date.getdate(); //獲取當前日 1-31

var hours = date.gethours();

var minutes = date.getminutes();

var secs = date.getseconds();

document.getelementbyid(nt).innerhtml = 當前時間是: + year + - + month + - + day + + caltime(hours) + : + caltime(minutes) + : + caltime(secs);

}

setinterval('updatenowtime()', 500);

</script>

</body>

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:javascript簡單實現(xiàn)時鐘的例子
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)