WordPress在网站底部添加网站运行时间代码精确到秒详细教程

分享给大家我博客下面的“网站在各种灾难中运行了时间”,精确到多少秒这个代码:

1.效果:

WordPress在网站底部添加网站运行时间代码精确到秒详细教程

2.方法:

首先我们先复制下面这一连串的代码网站的<header>

<script type="text/javascript">    function show_runtime() {        window.setTimeout("show_runtime()", 1000);        X = new Date("3/16/2025 10:28: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 = "网站在各种灾难中运行了: " + '<span style="color:red;">' + A + '</span>天'+ '<span style="color:red;">' + B + '</span>小时'+ '<span style="color:red;">' + C + '</span>分'+ '<span style="color:red;">' + D + '</span>秒'; }show_runtime();</script>

然后我们在想要显示代码的地方添加一下代码即可

<span id="runtime_span"></span>

或者,将两个代码合并在一起放置需要放置的位置,刷新页面即可正常显示。

© 版权声明

相关文章

没有相关内容!

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...