DDR爱好者之家 Design By 杰米

本文实例为大家分享了javascript实现智能手环时间显示的具体代码,供大家参考,具体内容如下

javascript实现智能手环时间显示

代码:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <style>
  #shijian{
   width: 500px;height: 120px;background-color:#117dbb;
   margin: 50px auto;line-height: 120px;
   color: white;font-size: 22px;
   text-align: center;
   border-radius: 60px;
   box-shadow:#4f535a 0px 5px 10px;
  }
 </style>
</head>
<body>
 <div id ="shijian">显示当前时间</div>
 <script>
  function showtime(){
   var a = new Date()
   var year = a.getFullYear()
   var month =jiaLing(a.getMonth()+1) 
   var day =jiaLing(a.getDate()) 
   var week = weekUp(a.getDay()) 
   var houer =jiaLing(a.getHours()) 
   var minute =jiaLing(a.getMinutes()) 
   var second =jiaLing(a.getSeconds()) 
   var str=year+"年"+month+"月"+day+"日 星期"+week+" " +houer+"时"+minute+"分"+second+"秒"
   return str;
  }
  function weekUp(i){
   var arr = ["日","一","二","三","四","五","六"]
   return arr[i]
  }
  function jiaLing(i){
   if(i<10){
    return "0"+i;
   }else{
    return i;
   }
  }
  setInterval(function(){
   var oDiv= document.getElementById("shijian");
   oDiv.innerHTML = showtime()
  },1000)
 </script>
</body>
</html>

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

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