admin

网站运行时间代码

admin 分享 2023-07-10 190浏览 0
<div style="color: #F08047;margin-top: -18px" class="ui inverted m-text-thin m-text-spaced">我的客栈已营业:<span id="htmer_time" class="item m-text-thin"></span> (*๓´╰╯`๓)</div>    
<script>    
// 运行时间统计    
function secondToDate(second) {    
if (!second) {    
return 0;    
}    
var time = new Array(0, 0, 0, 0, 0);    
if (second >= 365 * 24 * 3600) {    
time[0] = parseInt(second / (365 * 24 * 3600));    
second %= 365 * 24 * 3600;    
}    
if (second >= 24 * 3600) {    
time[1] = parseInt(second / (24 * 3600));    
second %= 24 * 3600;    
}    
if (second >= 3600) {    
time[2] = parseInt(second / 3600);    
second %= 3600;    
}    
if (second >= 60) {    
time[3] = parseInt(second / 60);    
second %= 60;    
}    
if (second > 0) {    
time[4] = second;    
}    
return time;    
}    
function setTime() {    
/*此处为网站的创建时间*/    
var create_time = Math.round(new Date(Date.UTC(2021, 6, 21, 15, 15, 15)).getTime() / 1000);    
var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);    
currentTime = secondToDate((timestamp - create_time));    
currentTimeHtml = currentTime[0] + '年' + currentTime[1] + '天'    
+ currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4]    
+ '秒';    
document.getElementById("htmer_time").innerHTML = currentTimeHtml;    
}    
setInterval(setTime, 1000);    
</script>


示例:


我的网站已运行: (*๓´╰╯`๓)
版权声明:
    “邓先生工作室”文章为自撰和网摘为一体,网摘文章及图片版权归原作者所有,转载本文请注明出处,请勿用于商务用途。如有侵犯您的权益,请及时联系toneydeng@qq.com予以删除!
发表评论