看到很多站长,都喜欢在自己网站的底部加入“本站已稳定运行多少天”的小功能 下面用js把功能复现一遍
JavaScript
function showsectime() { var birthDay = NewDate("2019-05-13"); // 这里修改站点开启日期 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();
html代码
<span id="showsectime"></span>
运用结果
本站部分文章搜集整理于互联网或者网友提供,如有侵权请联系站长
如若转载,请注明出处:https://htmlbk.com/web/1763.html
温馨提示:该文档最后一次修改时间为2022-09-22 10:58:44,请注意相关的内容是否还可用!