- 给网站添加运行时间显示
- 1.png
- 样式的话我没怎么调整,大家自己根据自己情况调整下
- js
function show_date_time() { window.setTimeout("show_date_time()", 1e3); var BirthDay = new Date("2020/04/01"),//在这里修改你的建站时间 today = new Date, timeold = today.getTime() - BirthDay.getTime(), msPerDay = 864e5, e_daysold = timeold / msPerDay, daysold = Math.floor(e_daysold), e_hrsold = 24 * (e_daysold - daysold), hrsold = Math.floor(e_hrsold), e_minsold = 60 * (e_hrsold - hrsold), minsold = Math.floor(60 * (e_hrsold - hrsold)), seconds = Math.floor(60 * (e_minsold - minsold)); qaqgzsyzsj.innerHTML = "安全运行:" + daysold + "天" + hrsold + "小时" + minsold + "分" + seconds + "秒"; } show_date_time();
- html
<span id="qaqgzsyzsj"></div>
【显示安全运行的js代码】
开始
完结