标签:
获取时间日期的jQuery代码:
1 function getNewtime(){ 2 3 var newtime = new Date(); 4 5 var yy = newtime.getYear().toString(); 6 7 yy = ‘20‘ + yy.substring(yy.length -2) ; 8 9 var mm =newtime.getMonth(); 10 11 var dd = newtime.getDate(); 12 13 if(dd<10){ 14 15 dd = ‘0‘ +dd.toString(); 16 17 } 18 19 var hh = newtime.getHours(); 20 21 if(hh <10){ 22 23 hh = ‘0‘ + hh.toString(); 24 25 } 26 27 var ss = newtime.getSeconds(); 28 29 if(ss <10){ 30 31 ss= ‘0‘ + ss.toString(); 32 33 } 34 35 var ww =newtime.getDay; 36 37 if( ww == ‘0‘){ 38 39 ww = ‘星期日‘ 40 41 }else if( ww == ‘1‘){ 42 43 ww = ‘星期1‘ 44 45 }else if( ww == ‘2‘){ 46 47 ww = ‘星期2‘ 48 49 }else if( ww == ‘3‘){ 50 51 ww = ‘星期3‘ 52 53 }else if( ww == ‘4‘){ 54 55 ww = ‘星期4‘ 56 57 }else if( ww == ‘5‘){ 58 59 ww = ‘星期5‘ 60 61 }else if( ww == ‘6‘){ 62 63 ww = ‘星期6‘ 64 65 } 66 67 var divstr = document.getElementById(‘divstr‘); 68 69 var divtime = " <div align = center> " + yy +"年 " + (mm+1) + "月" + dd + "日" +hh + "时" + ss+ " 分" + "</div><hr> <div align = center> "+ mm+"</div>" ; 70 if(divstr != null)divstr.innerHTML = divtime; 71 setTimeout(getNewtime,1000); 72 73 } 74 getNewtime()
标签:
原文地址:http://www.cnblogs.com/hao5599/p/4555320.html