JavaScript 时间显示

<span id="localtime"><span>
<script type="text/javascript">
function showLocalTime(OID) {
    window.setTimeout(function(){
        var today = new Date(),
              arr = new Array(‘日‘, ‘一‘, ‘二‘, ‘三‘, ‘四‘, ‘五‘, ‘六‘),
               yy = today.getYear(),
               mm = today.getMonth()+1,
               dd = today.getDate(),
               hh = today.getHours(),
               ii = today.getMinutes(),
               ss = today.getSeconds(),
               ww = today.getDay();
        yy = yy < 1900 ? yy + 1900 : yy;
        mm = mm < 10 ? ‘0‘ + mm : mm;
        dd = dd < 10 ? ‘0‘ + dd : dd;
        hh = hh < 10 ? ‘0‘ + hh : hh;
        ii = ii < 10 ? ‘0‘ + ii : ii;
        ss = ss < 10 ? ‘0‘ + ss : ss;
        document.getElementById(OID).innerHTML = yy + ‘-‘ + mm + ‘-‘ + dd + ‘ ‘ + hh+‘:‘+ii+‘:‘+ss + ‘ 星期‘ + arr[ww];
        showLocalTime(OID);
    }, 1000);
}
showLocalTime(‘localtime‘);

 

JavaScript 时间显示,布布扣,bubuko.com

JavaScript 时间显示

上一篇:转 Java多线程中Sleep与Wait的区别


下一篇:Qt移动应用开发(七):QML与Java的交互