how to use javascript show the time?
code:
<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
使用Javascript显示时间
原创magic_180 ©著作权
文章标签 html javascript 文章分类 后端开发
上一篇:2.6.14 内核移植说明文档
-
day.js 时间戳
day.js 的时间戳 希望大家可以补充
时间段 时间戳 时间处理 -
十分钟时间搞懂怎么用JS代码渲染实时时间
十分钟时间搞懂怎么用JS代码渲染实时时间
数据 数组 时间对象