posts - 68, comments - 19, trackbacks - 0, articles - 1

动态时钟

Posted on 2010-10-03 22:07 viery 阅读(107) 评论(0)  编辑  收藏 所属分类: Javascript

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>

<script language="javascript">
function datetime1()
{
 AllMyDate=new Date() ;
var MyYear=AllMyDate.getYear();
var MyMonth=AllMyDate.getMonth()+1;
if(MyMonth<10)
MyMonth="0"+MyMonth;

var MyDate=AllMyDate.getDate();
if(MyDate<10)
MyDate="0"+MyDate;
var MyHours=AllMyDate.getHours();
if(MyHours<10)
MyMyHours="0"+MyHours;
var MyMinutes=AllMyDate.getMinutes();
if(MyMinutes<10)
MyMinute="0"+MyMinute;
var MySeconds=AllMyDate.getSeconds();
if( MySeconds<10)
MySeconds="0"+ MySeconds;

my.innerHTML="现在时间:"+MyYear+"年"+MyMonth+"月"+ MyDate+"日"+
MyHours+"点"+MyMinutes+"分"+MySeconds+"秒";
setTimeout("datetime1()",1000);
}
</script>
</head>
<body onLoad="datetime1()">
<div id="my"></div>
</body>
</html>


只有注册用户登录后才能发表评论。


网站导航: