计算网页运行时间

一 代码

<!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>

 

二 运行结果

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值