首页 > 网站 > 在网站下添加网站运行时间

AI 摘要

这篇文章提供了在网站底部添加网站运行时间的代码和调用方法。添加的代码可以在footer.php文件中,位置在</body>的前面。调用代码可以在需要的地方填写,然后预览网站即可。在代码中,可以根据需要更改时间。

食用

添加代码

footer.php里添加代码,位置在</body>的前面

<script type="text/javascript">
    function show_runtime() {
        window.setTimeout("show_runtime()", 1000);
        X = new Date("月/日/年 时:分:秒");  // 按照时间更改
        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>
在网站下添加网站运行时间插图

调用

在需要的地方填写一下代码:

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

预览

在网站下添加网站运行时间插图1

相关文章