js显示当前时间

<html>
  <head>
    <title>js实现当前日期显示</title>

   
  </head>

  <body style="text-align: center">

    <div>
      <span id="curTime" style="font-size: 18px;color: #00be67"></span>
    </div>

  </body>

  <script type="text/javascript" charset="utf-8">

$(function(){
  var date = new Date();
          var weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
          var year = date.getFullYear();
          var month = date.getMonth()+1;
          var day = date.getDate();
          var week = weekDay[date.getDay()];         
          $("#curTime").html(year+"年"+month+"月"+day+"日&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp"+week);

})
</script> </html>
posted @ 2018-07-03 11:30  挚爱无痕  阅读(711)  评论(0编辑  收藏  举报