JS获取时间的方法
本文实例讲述了JS获取时间的方法。分享给大家供大家参考。具体实现方法如下:
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<scripttype="text/javascript">
functionCase(i){
if(i<10){
i="0"+i;
}
returni;
}
functiongetdata(){
varbnt=document.getElementById("id1")
vardate=newDate();
bnt.value=Case(date.getHours())+":"+Case(date.getMinutes())+":"+Case(date.getSeconds());
}
</script>
</head>
<body>
<inputtype="button"value="获取时间"id="id1"onclick="setInterval(getdata,1000)"/>
</body>
</html>
希望本文所述对大家的javascript程序设计有所帮助。