1 <?php 2 3 date_default_timezone_set ( "Asia/Shanghai" ); 4 $kaimu = mktime ( 4, 0, 0, 07, 28, 2012 ); 5 //echo date ( "Y-m-d H:i:s", $kaimu ); 6 //echo "<br/>"; 7 //echo date ( "Y-m-d H:i:s", time () ); 8 $timecha = $kaimu - time (); 9 10 mkdaojishi ( $timecha ); 11 function mkdaojishi($timecha) { 12 $miao = $timecha % 60; 13 $fen = floor ( $timecha / 60 ); 14 15 if ($fen > 60) { 16 $shi = floor ( $fen / 60 ); 17 $fen=$fen%60; 18 } 19 20 if ($miao<10){$miao="0".$miao;} 21 if ($fen<10){$fen="0".$fen;} 22 if ($shi<10){$shi="0".$shi;} 23 $dangqian=date("Y-m-d H:i:s",time()); 24 echo "当前时间:$dangqian,<b>距伦敦奥运会开幕还有:<font color='red'>$shi:$fen:$miao</font></b>"; 25 } 26 27 ?>