获取时间日期的jQuery代码:
function getNewtime(){ var newtime = new Date(); var yy = newtime.getYear().toString(); yy = ‘20‘ + yy.substring(yy.length -2) ; var mm =newtime.getMonth(); var dd = newtime.getDate(); if(dd<10){ dd = ‘0‘ +dd.toString(); } var hh = newtime.getHours(); if(hh <10){ hh = ‘0‘ + hh.toString(); } var ss = newtime.getSeconds(); if(ss <10){ ss= ‘0‘ + ss.toString(); } var ww =newtime.getDay; if( ww == ‘0‘){ ww = ‘星期日‘ }else if( ww == ‘1‘){ ww = ‘星期1‘ }else if( ww == ‘2‘){ ww = ‘星期2‘ }else if( ww == ‘3‘){ ww = ‘星期3‘ }else if( ww == ‘4‘){ ww = ‘星期4‘ }else if( ww == ‘5‘){ ww = ‘星期5‘ }else if( ww == ‘6‘){ ww = ‘星期6‘ } var divstr = document.getElementById(‘divstr‘); var divtime = " <div align = center> " + yy +"年 " + (mm+1) + "月" + dd + "日" +hh + "时" + ss+ " 分" + "</div><hr> <div align = center> "+ mm+"</div>" ; if(divstr != null)divstr.innerHTML = divtime; setTimeout(getNewtime,1000); } getNewtime()
本文出自 “kosig” 博客,请务必保留此出处http://kosig.blog.51cto.com/9218084/1911204
原文地址:http://kosig.blog.51cto.com/9218084/1911204