网页加载时间
/**
* 网页加载时间
*/
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;
}
调用方法:
本次加载耗时:<?php echo timer_stop();>
显示建站时间
/**
* 建站时间
*/
function getBuildTime() {
// 在下面按格式输入本站创建的时间
if ( empty( Helper::options()->createTime ) )
$ct = '2016-12-23 13:59:00';
else
$ct = Helper::options()->createTime;
$site_create_time = strtotime( $ct );
$time = time() - $site_create_time;
$time = floor( $time / 86400 );
echo '<span class="time">' . '本站已运行 ' . $time . ' 天.' . '</span>';
}
调用方法:
<?php getBuildTime();>
此处评论已关闭