网站运行时间代码
非常简单的网站站长记录网站运行多少时间js代码,源代码里,只需把代码中的:var birthDay =NewDate(“2020-05-07”)日期改成建站日期即可!
<strong> <center> <span id="showsectime" style="color:#FF0000;"></span> <script type="text/javascript"> function NewDate(str) { str = str.split('-'); var date = new Date(); date.setUTCFullYear(str[0], str[1] - 1, str[2]); date.setUTCHours(0, 0, 0, 0); return date; } function showsectime() { var birthDay =NewDate("2020-05-07"); var today=new Date(); var timeold=today.getTime()-birthDay.getTime(); var sectimeold=timeold/1000 var secondsold=Math.floor(sectimeold); var msPerDay=24*60*60*1000; var e_daysold=timeold/msPerDay; var daysold=Math.floor(e_daysold); var e_hrsold=(daysold-e_daysold)*-24; var hrsold=Math.floor(e_hrsold); var e_minsold=(hrsold-e_hrsold)*-60; var minsold=Math.floor((hrsold-e_hrsold)*-60); var seconds=Math.floor((minsold-e_minsold)*-60).toString(); document.getElementById("showsectime").innerHTML = "本站已运行"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒"; setTimeout(showsectime, 1000); }showsectime(); </script> <strong/>
原文链接:https://www.qiquanji.com/post/9268.html
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。
微信扫码关注
更新实时通知