亲宝软件园·资讯

展开

js智能手环时间显示 javascript实现智能手环时间显示

疯人Gort 人气:0
想了解javascript实现智能手环时间显示的相关内容吗,疯人Gort在本文为您仔细讲解js智能手环时间显示的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:js智能手环时间显示,js手环时间显示,js时间显示,下面大家一起来学习吧。

代码:

<!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>

加载全部内容

相关教程
猜你喜欢
用户评论