js显示日期星期与动态时间

发布时间:2008年11月07日      浏览次数:780 次
<div id="date_time_html"></div>
      <script language="javascript">
      <!--
            function showTime(){
                  var day_array = Array("<font color=red>日</font>","一","二","三","四","五","<font color=red>六</font>");
                  var now = new Date();
                  var year = now.getFullYear();
                  var month = now.getMonth()+1;
                  var date = now.getDate();
                  var day = now.getDay();
                  var week = day_array[day];
                  var hours = now.getHours();
                  var mins = now.getMinutes();
                  var secs = now.getSeconds();
                  var date_time = "今天是:";
                  date_time += year+"年";
                  date_time += month+"月";
                  date_time += date+"日 ";
                  date_time += " 星期"+week;
                  date_time += " "+ ((hours<10) ? "0" : "") + hours ;
                  date_time += ((mins<10) ? ":0" : ":") + mins;
                  date_time += ((secs<10) ? ":0" : ":") + secs;
            
                  document.getElementById("date_time_html").innerHTML = date_time;
            }
            function startClock(){
             showTime();
             window.setInterval("showTime()",1000);
            }
            startClock();
      -->
      </script>
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!