一 代码
Php代码
- <!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"> </td>
- <td width="287"> </td>
- <td width="99"> </td>
- </tr>
- <tr>
- <td height="95"> </td>
- <td align="left" valign="top"><?php echo "距离2009年国庆节还有<font color=red> $sub1 </font>小时!!!" ; ?></td>
- <td> </td>
- </tr>
- <tr>
- <td height="50"> </td>
- <td align="left" valign="top"><?php echo "距离2009年元旦还有<font color=red>$sub2 </font>天!!!"; ?></td>
- <td> </td>
- </tr>
- <tr>
- <td height="215"> </td>
- <td align="left" valign="top">本示例的运行时间为<font color=blue> <?php echo ($end_time - $start_time); ?> </font>秒</td>
- <td> </td>
- </tr>
- </table>
- </body>
- </html>
二 运行结果