MENU

Catalog

    网站底部添加网站运行时间代码

    March 29, 2021 • Read: 685 • 默认分类

    1. 直接粘贴代码(一般放到 html 的 </body> 标签之前),Date("10/11/2017 7:00:00") 改成自己要的时间

    <script type="text/javascript">
        function show_runtime() {
            window.setTimeout("show_runtime()", 1000);
            X = new Date("10/11/2017 7: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>
    
    

    1. 在哪个地方显示就贴下下面的代码(一般在footer)

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

    - - - The END - - -
  • 文章作者:谭先生
  • 版权所有:文章转载时,注明出处即可!
  • 本站部分资源收集于网络,纯个人收藏,无商业用途,如有侵权请及时告知!
  • Last Modified: August 4, 2021
    Archives QR Code Tip
    QR Code for this page
    Tipping QR Code
    阅读:685