欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

计算网页运行时间

程序员文章站 2022-03-10 20:00:44
...

一 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>计算页面的运行时间</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 13px;
}
body {
	margin-left: 10px;
	margin-top: 10px;
	margin-right: 10px;
	margin-bottom: 10px;
}
-->
</style></head>
<body>
<div align="center">
<?php
function run_time()
{
    list($msec, $sec) = explode(" ", microtime());
    return ((float)$msec + (float)$sec);
}
	 $start_time = run_time();
     $time1 = strtotime(date( "Y-m-d H:i:s"));
     $time2 = strtotime("2017-10-01 00:00:00");			//2009年国庆节
     $time3 = strtotime("2017-01-01 ");					//2009年元旦
	 $sub1 = ceil(($time2 - $time1) / 3600);			//60 * 60
     $sub2 = ceil(($time3 - $time1) / 86400);			//60 * 60 * 24
	 $end_time = run_time();
?> 
<p>
</div>
<table width="500" height="502" border="0" cellpadding="0" cellspacing="0" background="images/bg.jpg">
  <tr>
    <td width="92" height="140">&nbsp;</td>
    <td width="287">&nbsp;</td>
    <td width="99">&nbsp;</td>
  </tr>
  <tr>
    <td height="95">&nbsp;</td>
    <td align="left" valign="top"><?php  echo "距离2009年国庆节还有<font color=red> $sub1 </font>小时!!!" ;  ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="50">&nbsp;</td>
    <td align="left" valign="top"><?php  echo "距离2009年元旦还有<font color=red>$sub2 </font>天!!!"; ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="215">&nbsp;</td>
    <td align="left" valign="top">本示例的运行时间为<font color=blue> <?php echo ($end_time - $start_time); ?> </font>秒</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

 

二 运行结果
计算网页运行时间
 
相关标签: 计算 运行时间