DDR爱好者之家 Design By 杰米

本文实例为大家分享了js动态时间显示 的具体代码,供大家参考,具体内容如下

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js动态时间显示 </title>
</head>

<body id = "show">
 
<script>
 
 
 function run(){
 var time = new Date();//获取系统当前时间
 var year = time.getFullYear();
 var month = time.getMonth()+1;
 var date= time.getDate();//系统时间月份中的日
 var day = time.getDay();//系统时间中的星期值
 var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
 var week = weeks[day];//显示为星期几
 var hour = time.getHours();
 var minutes = time.getMinutes();
 var seconds = time.getSeconds();
 console.log(seconds);
 if(month<10){
 month = "0"+month; 
 }
 if(date<10){
 date = "0"+date; 
 }
 if(hour<10){
 hour = "0"+hour; 
 }
 if(minutes<10){
 minutes = "0"+minutes; 
 }
 if(seconds<10){
 seconds = "0"+seconds; 
 }
 //var newDate = year+"年"+month+"月"+date+"日"+week+hour+":"+minutes+":"+seconds;
 document.getElementById("show").innerHTML = year+"年"+month+"月"+date+"日"+week+hour+":"+minutes+":"+seconds;
 setTimeout('run()',1000);
 }
 
 run();

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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米