- 论坛徽章:
- 0
|
- <!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>
- </head>
- <body>
- <?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("2012-2-8 16:30:00");
- $time3 = strtotime("2013-1-1");
- $sub1 = ceil(($time2 - $time1) / 3600);
- $sub2 = ceil(($time3 - $time1) /86400);
- echo "离放假还有<font color=red> $sub1 </font>小时!!!";
- echo "<p>";
- echo "离2013年元旦还有<font color=red>$sub2</font>天!!!";
- echo "<p>";
- $end_time = run_time();
- //$runtime=$end_time-$start_time;
- //echo $runtime;
- ?>
- <font color=blue><?php echo"程序运行时间为:".($end_time-$start_time);?></font>秒
- </body>
- </html>
复制代码 |
|