欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

js数目字时钟

更新时间: 2014-01-05 01:51:14 责任编辑: Author_N1

 

js数字时钟


js数字时钟,效果如下:




<html>
	<head>
		 <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
	</head>

	<body>
		<span id="datetime" style="color: red"></span>
	</body>

 
 <script type="text/javascript">
	setTime();
  function setTime(){
      var mydate=new Date();
      var year = mydate.getFullYear();
      var mymonth=parseInt(mydate.getMonth()+1)<10?"0"+(mydate.getMonth()+1):mydate.getMonth()+1;
      var myday= mydate.getDate();
      var myweekday=mydate.getDay();
   	  var myHours = parseInt(mydate.getHours())<10?"0"+(mydate.getHours()):mydate.getHours();
      var myMinutes = mydate.getMinutes()<10?"0"+mydate.getMinutes():mydate.getMinutes();
      var mySeconds = parseInt(mydate.getSeconds())<10?"0"+mydate.getSeconds():mydate.getSeconds();
      if(myweekday == 0)
      weekday=" 星期日 ";
      else if(myweekday == 1)
      weekday=" 星期一 ";
      else if(myweekday == 2)
      weekday=" 星期二 ";
      else if(myweekday == 3)
      weekday=" 星期三 ";
      else if(myweekday == 4)
      weekday=" 星期四 ";
      else if(myweekday == 5)
      weekday=" 星期五 ";
      else if(myweekday == 6)
      weekday=" 星期六 ";
     datetime.innerHTML=year+"年"+mymonth+"月"+myday+"日 "+myHours+":"+myMinutes+":"+mySeconds+" "+weekday;
  	 setTimeout("setTime()",1000);
  }
  </script>
</html>
上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 01:51:14
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/2052/
本文WWW.DOC100.NET DOC100.NET版权所有。