天天看點

網站底部運作時間的php代碼,在wordpress網站底部添加運作時間和加載時間

效果如下圖

網站底部運作時間的php代碼,在wordpress網站底部添加運作時間和加載時間

代碼加到footer.php底部

網站底部運作時間的php代碼,在wordpress網站底部添加運作時間和加載時間

完整代碼如下:

本次查詢<?php echo get_num_queries(); ?> 次 用時<?php timer_stop(1); ?> 秒

已穩定運作

function runTime() {

var d = new Date(), str = '';

BirthDay = new Date("2019-3-8");

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);