php生成时间表,世界时钟
(2011-07-26 11:25)
分类: php研究
完全代码如下:
<title>世界时钟</title>
<!--每一秒刷洗一次-->
<html>
<meta http-equiv="refresh"Content="1;url=clock.php">
</html>
<!--css页面设置,对表格进行控制-->
<style>
form{
margin:0px;
padding:0px;
}
td{
text-align:center;
width:40px;
}
</style>
<?php
header("Content-Type:text/html;charset=GB2312"); //设置字符集
function show_clock($zonetime) { //显示时钟函数
$Year = date('Y');
$Month = date('m');
$Day = date('d');
$Hour = date('H');
$Min = date('i');
$Sec = date('s');
$clock = array('年','月','日','时','分','秒');
//$time = array($Year,$Month,$Day,$Hour,$Min,$Sec);
echo '<table border = "1">';
echo '<tr><td colspan=6 style="text-align:center">'.$zonetime.'</td></td>';
echo '<tr>';
$i = 0;
for ($i=0;$i<6;$i++){
echo '<td>'.$clock[$i].'</td>';
}
echo '</tr><tr>';
echo '<td>'.$Year.'</td>';
echo '<td>'.$Month.'</td>';
echo '<td>'.$Day.'</td>';
echo '<td>'.$Hour.'</td>';
echo '<td>'.$Min.'</td>';
echo '<td style="color:red">'.$Sec.'</td>';
echo '</tr>';
echo '</table><br />';
}
show_clock('北京时间');
if(function_exists(date_default_timezone_set)){
date_default_timezone_set('America/New_York');
}
show_clock('纽约时间');
if(function_exists(date_default_timezone_set)){
date_default_timezone_set('Australia/West');
}
show_clock('澳大利亚时间');
if(function_exists(date_default_timezone_set)){
date_default_timezone_set('Europe/London');
}
show_clock('伦敦时间');
if(function_exists(date_default_timezone_set)){
date_default_timezone_set('Europe/Paris');
}
show_clock('巴黎时间');
if(function_exists(date_default_timezone_set)){
date_default_timezone_set('Japan');
}
show_clock('日本时间');
?>
效果如下:
| 北京时间 | |||||
| 年 | 月 | 日 | 时 | 分 | 秒 |
| 2011 | 07 | 26 | 11 | 24 | 56 |
| 纽约时间 | |||||
| 年 | 月 | 日 | 时 | 分 | 秒 |
| 2011 | 07 | 25 | 23 | 24 | 56 |
| 澳大利亚时间 | |||||
| 年 | 月 | 日 | 时 | 分 | 秒 |
| 2011 | 07 | 26 | 11 | 24 | 56 |
| 伦敦时间 | |||||
| 年 | 月 | 日 | 时 | 分 | 秒 |
| 2011 | 07 | 26 | 04 | 24 | 56 |
| 巴黎时间 | |||||
| 年 | 月 | 日 | 时 | 分 | 秒 |
| 2011 | 07 | 26 | 05 | 24 | 56 |
| 日本时间 | |||||
| 年 | 月 | 日 | 时 | 分 | 秒 |
| 2011 | 07 | 26 | 12 | 24 | 56 |

