wordpress底部添加加载时间和运行时间
wordpress底部添加加载时间和运行时间
<font size="2" color="#808080">页面加载用时<?php timer_stop(1); ?> s</font>
<font size="2" color="#808080">网站已运行:<span id="run_time" style="color: #808080;"></span></font>
<script>
function runTime() {
var d = new Date(), str = '';
BirthDay = new Date("2021-12-15");
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>
</div>
</div>
</div>
</div>
License:
CC BY 4.0