asp.net/javascript 显示时间 秒跳动显示

显示动态时间

10:14:36

Today it is Sunday
将当前日期转换成字符串
Sun, 9 Aug 2009 02:11:38 UTC

<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>
显示动态时间<br>
<body onload="startTime()">
<div id="txt"></div>

<script type="text/javascript">
var d=new Date()
var weekday=new Array(7)
weekday[0]="Sunday"
weekday[1]="Monday"
weekday[2]="Tuesday"
weekday[3]="Wednesday"
weekday[4]="Thursday"
weekday[5]="Friday"
weekday[6]="Saturday"
document.write("Today it is " + weekday[d.getDay()])
</script>
<br>
将当前日期转换成字符串<br>
<script type="text/javascript">
var d = new Date()
document.write (d.toUTCString())
</script>

</body>
</html>

 

http://zhidao.baidu.com/question/71061731.html?fr=qrl&fr2=query

posted @ 2009-08-09 10:17  emanlee  阅读(818)  评论(0编辑  收藏  举报