码迷,mamicode.com
首页 > Web开发 > 详细

用JS实现实时显示系统时间

时间:2017-10-27 15:30:22      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:b2c   date   doctype   nts   htm   second   java   col   ext   

 

技术分享

 

下面为大家附上代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS时间</title>
<style>
</style>        
</head>
<body>
<div id="time"></div>
<script type="text/javascript">
function time(){
var vWeek,vWeek_s,vDay;
vWeek = ["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];
var date =  new Date();
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
hours = date.getHours();
minutes = date.getMinutes();
seconds = date.getSeconds();
vWeek_s = date.getDay();
document.getElementById("time").innerHTML = year + "" + month + "" + day + "" + "\t" + hours + ":" + minutes +":" + seconds + "\t" + vWeek[vWeek_s] ;

};
setInterval("time()",1000);

</script>
</body>
</html>

 

如果有错误或者有更好的方法实现效果,欢迎您来指导!!!

 

用JS实现实时显示系统时间

标签:b2c   date   doctype   nts   htm   second   java   col   ext   

原文地址:http://www.cnblogs.com/yidaixiaohui/p/7742746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!