网站JS时间刷新显示代码:
废话少说,先看效果:
var myDate,year,month,day,date,weeks,weekday,hour,min,sec;function run(){ myDate = new Date(); year = myDate.getFullYear(); month = myDate.getMonth()+1; month = month>9 ? month : "0"+month; day = myDate.getDate(); date = year+"年"+month+"月"+day+"日";
weeks =['星期日','星期一','星期二','星期三','星期四','星期五','星期六']; weekday = weeks[myDate.getDay()];
hour = myDate.getHours(); hour = hour>9 ? hour :"0"+hour; min = myDate.getMinutes(); min = min>9 ? min : "0"+min; sec = myDate.getSeconds(); sec = sec>9 ? sec : "0"+sec; document.getElementById("time").innerHTML=date+"("+weekday+")"+hour+":"+min+":"+sec;}setInterval(run,1000);//浏览器刷新
html代码:现在是:<span id="time"></span>
转载于:https://www.cnblogs.com/SandyLee/p/3759181.html
相关资源:js获取服务器的时间(不是本地时间哦)