给博客底部添加网站运行时间

发表于 2020-12-28 00:00 121 字 1 min read

补档

之前网站就很喜欢给 footer 添加各种各样的东西,其中之一就是网站运行时间。

代码

在 footer.php 中找到合适的位置添加代码:

<span id="runtime_span" style="color: #b9b9b9;"></span>
<!--建站时间-->
<script type="text/javascript">
function show_runtime()
{window.setTimeout("show_runtime()",1000);X=new 
Date("1/1/2021 00:00:00");
Y=new Date();T=(Y.getTime()-X.getTime());M=24*60*60*1000;
a=T/M;A=Math.floor(a);b=(a-A)*24;B=Math.floor(b);c=(b-B)*60;C=Math.floor((b-B)*60);D=Math.floor((c-C)*60);
runtime_span.innerHTML="网站已在暴风骤雨中运行: "+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime();
</script>

建站时间修改第六行 Date 里的时间就行了。

效果

划到最底下就可以看到了。

给博客底部添加网站运行时间
https://lowbee.icu/post/2020-12-28-%E7%BB%99%E5%8D%9A%E5%AE%A2%E5%BA%95%E9%83%A8%E6%B7%BB%E5%8A%A0%E7%BD%91%E7%AB%99%E8%BF%90%E8%A1%8C%E6%97%B6%E9%97%B4/
作者
汉堡肉大王
发布于
2020-12-28
最后更新于
2026-11-13
许可协议
不要转载|去热爱自己的生活

喜欢的话,留下你的评论吧~

© 2015 - 2026 汉堡肉大王 @singleBee
Powered by theme astro-koharu · Inspired by Shoka