时间自动在走

 <div style="width: 400px;"><span id="clock"  ></span></div>

 

 

<script type="text/javascript">
  window.onload =function() {x=window.setInterval(function(){
          var now = new Date();  //获取 Date对象
          var year = now.getFullYear(); //获取年份
          var month = now.getMonth(); //获取月份
          var day = now.getDate();  //呼气日期
          var weeker = now.getDay() //获取星期
          var hour = now.getHours() //获取小时
          var minu = now.getMinutes();//获取分钟
          var secon = now.getSeconds(); //获取秒
          month = month+1;
          //获取中文星期几
          var arr_week = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
          var week = arr_week[weeker];
          var time = year+"年"+month+"月"+day+"日"+week+" "+hour+":"+minu+":"+secon;
         ;
          $("#clock").empty();
        $("#clock").append(time);
       },1000);
  }
  </script>

 

posted @ 2018-05-09 17:01  zhouwen周文  阅读(94)  评论(0编辑  收藏  举报