实时显示系统时间

原文链接:http://www.cnblogs.com/zhengchubin/archive/2012/10/09/2716615.html
function clockon(bgclock){
    var now=new Date();
    var year=now.getYear();
    var month=now.getMonth();
    var date=now.getDate();
    var day=now.getDay();
    var hour=now.getHours();
    var minu=now.getMinutes();
    var sec=now.getSeconds();
    var week;
    month=month+1;
    if(month<10) month="0"+month;
    if(date<10) date="0"+date;
    if(hour<10) hour="0"+hour;
    if(minu<10) minu="0"+minu;
    if(sec<10) sec="0"+sec;
    var arr_week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
    week=arr_week[day];
    var time="";
    time=year+"年"+month+"月"+date+"日 "+week+" "+hour+":"+minu+":"+sec;
    if(document.all){
        bgclock.innerHTML="["+time+"]"
    }
    var timer=setTimeout("clockon(bgclock)",200);
  <body οnlοad="clockon(bgclock)">
  <table><tr><td id="bgclock"></td></tr></table>
    This is my JSP page. <br>
  </body>

 

转载于:https://www.cnblogs.com/zhengchubin/archive/2012/10/09/2716615.html

展开阅读全文
博主设置当前文章不允许评论。

没有更多推荐了,返回首页