WordPress网站稳定运行时间代码

本文最后更新于2022.07.01-16:10,某些文章具有时效性,若有错误或已失效,请在下方留言或联系涛哥

效果

 

代码

本站稳定运行 <span id="span_dt_dt" style="color: #0196e3;"></span>
                        <script language="javascript">
                            function show_date_time(){
                                window.setTimeout("show_date_time()", 1000);
                                    BirthDay=new Date("11/15/2021 09:00:00");
                                    today=new Date();
                                    timeold=(today.getTime()-BirthDay.getTime());                                    
                                    sectimeold=timeold/1000
                                    secondsold=Math.floor(sectimeold);
                                    msPerYear = 365 * 24 * 60 * 60 * 1000;
                                    msPerDay=24*60*60*1000;
                                    e_yearsold = timeold / msPerYear;
                                    yearsold = Math.floor(e_yearsold);
                                    e_daysold=timeold/msPerDay
                                    daysold=Math.floor(e_daysold);
                                    e_hrsold=(e_daysold-daysold)*24;
                                    hrsold=Math.floor(e_hrsold);
                                    e_minsold=(e_hrsold-hrsold)*60;
                                    minsold=Math.floor((e_hrsold-hrsold)*60);
                                    seconds=Math.floor((e_minsold-minsold)*60);
                                    span_dt_dt.innerHTML=yearsold +"年"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";
                                    }
                                    show_date_time();
                            </script>
                        <br>
                        <font color="#99a9bf">
                            本页面此次加载用时<span style="color:#0196e3"><?php echo wp_page_speed($content) ?></span>
                            <p>
                                <?php wb_echo_site_count(); ?>
                                <span style="color:#0196e3"><?php echo  show_online_count();?></span>人
                            </p>
                        </font>
网站已稳定运行:<span id="run_time" style="color:red;"></span>
<script>
function runTime() {
    var d = new Date(), str = '';
    BirthDay = new Date("2022-05-10");
    today = new Date();
    timeold = (today.getTime() - BirthDay.getTime());
    sectimeold = timeold / 1000
    secondsold = Math.floor(sectimeold);
    msPerDay = 24 * 60 * 60 * 1000
    msPerYear = 365 * 24 * 60 * 60 * 1000
    e_daysold = timeold / msPerDay
    e_yearsold = timeold / msPerYear
    daysold = Math.floor(e_daysold);
    yearsold = Math.floor(e_yearsold);
    str = yearsold + "年";
    str += daysold + "天";
    str += d.getHours() + '时';
    str += d.getMinutes() + '分';
    str += d.getSeconds() + '秒';
    return str;
}

setInterval(function () {
    $('#run_time').html(runTime())
}, 1000);
</script>
阅读剩余
THE END