1、添加网站运行时间
在footer.php中的</footer>上面添加
<span id = "runtime_span"></span>
<script type = "text/javascript">
function show_runtime()
{window.setTimeout("show_runtime()",1000);X=new
Date("1/01/2021 00: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>
#2、添加加载时间
在Cuteen/functions.php添加以下内容
/**
* 加载时间 以下为添加内容
*
@return
bool
*/
function timer_start() {
global $timestart;
$mtime = explode( ' ', microtime() );
$timestart = $mtime[1] + $mtime[0];
return true;
}
timer_start();
function timer_stop( $display = 0, $precision = 3) {
global $timestart, $timeend;
$mtime = explode( ' ', microtime() );
$timeend = $mtime[1] + $mtime[0];
$timetotal = number_format( $timeend - $timestart, $precision );
$r = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s";
if ( $display ) {
echo $r;
}
return $r;
}
之后在footer.php中的</footer>上面添加
加载耗时:<?php echo timer_stop();?>
评论 (0)