5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2015-08-27
http://zhanyu.5d.cn/
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/06/17 | 世界各地时间代码
类别(网页制作)
|
评论
(0)
|
阅读(1072)
|
发表于 20:39
世界各地时间代码
<!-- 用<body bgcolor="#fef4d9" OnLoad="timeCheck(timezone, 0)">替换原有的<body> -->
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language="javascript">
<!-- Begin
var timerRunning = false;
var timezone = "这是格林尼治标准时间";
var adjust = 0;
function timeCheck(tzone, diff) {
if (timerRunning) {
clearTimeout(updatetime);
timerRunning = false; }
gmtOffset=eval(diff+adjust);
timezone = tzone;
checkDateTime();
}
function checkDateTime () {
var today = new Date();
var year = today.getYear() + 00;
var month = today.getMonth()+1;
var date = today.getDate();
var day = today.getDay();
var hour = today.getHours();
var minute = today.getMinutes();
var second = today.getSeconds();
var lastSat = date - (day+1);
while (lastSat < 32) lastSat+=7;
if (lastSat > 31) lastSat+=-7;
var firstSat = date - (day+1);
while (firstSat > 0) firstSat+=-7;
if (firstSat < 1) firstSat+=7;
if ((((month == 4) && (date >= firstSat)) || month > 4) &&
(month < 11 || ((month == 10) && day <= lastSat))) adjust += 60;
yourOffset = (new Date()).getTimezoneOffset();
yourOffset = yourOffset + adjust;
var xx = navigator.appName
var xy = navigator.appVersion;
xy = xy.substring(0,1);
if ((xy == 4) && (xx == "Netscape")) yourOffset = yourOffset+adjust;
if ((((month == 4) && (date > 20)) || month > 4) && (month < 11 || ((month == 10) &&
day < 30))) adjust -= 60;
ourDifference = eval(gmtOffset - yourOffset);
var half = eval(ourDifference % 60);
ourDifference = Math.round(ourDifference / 60);
hour = eval(hour - ourDifference);
var m = new Array("",
"1","2","3",
"4","5","6",
"7","8","9",
"10","11","12");
var leap = eval(year % 4);
if ((half == -30) || (half == 30)) minute += 30;
if (minute > 59) minute -= 60, hour++;
if (minute < 0) minute += 60, hour--;
if (hour > 23) hour -= 24, date += 1;
if (((month == 4) || (month == 6) ||
(month == 9) || (month == 11)) && (date==31)) date = 1, month ++;
if (((month == 2) && (date > 28)) && (leap != 0)) date = 1, month ++;
if ((month == 2) && (date > 29)) date = 1, month++;
if (hour < 0) hour += 24, date --;
if ((date == 32) && (month == 12)) month = m[1], date = 1, year++;
if (date == 32) date = 1, month++;
if ((date < 1) && (month == 1)) month= m[12], date = 31, year--;
if (date < 1) date = 31, month --;
if (((month == 4) || (month == 6) ||
(month== 9) || (month == 11)) && (date == 31)) date = 30;
if ((month == 2) && (date > 28)) date = 29;
if (((month == 2) && (date > 28)) && (leap != 0)) date=28;
for (i=1; i<13; i++) {
if (month == i) {
month = m[i]; break;
}
}
var dateTime = hour;
dateTime = ((dateTime < 10) ? "0":"") + dateTime;
dateTime = " " + dateTime;
dateTime += ((minute < 10) ? ":0" : ":") + minute;
dateTime += ((second < 10) ? ":0" : ":") + second;
dateTime += (hour >= 12) ? "下午, " : "上午, ";
dateTime += year + "年" + month + "月" + date + "日" ;
document.clock.zonetime.value = dateTime;
document.clock.zonename.value = timezone;
updatetime=setTimeout("checkDateTime()", 900);
timerRunning = true;
}
// End -->
</script>
<br>
<form name=clock>
<table border=1 cellpadding=0 cellspacing="0">
<tr>
<td align=center colspan="3">
<input type=text name=zonetime size=28>
</td>
</tr>
<tr>
<td align=center colspan="3">
地区:<input type=text name=zonename size=20>
</td>
</tr>
<tr>
<td align=center>
<input type=button value="太平洋" onClick="timeCheck(this.value, +480)" name="button3">
</td>
<td align=center>
<input type=button value="中 心" onClick="timeCheck(this.value, +420)" name="button2">
</td>
<td align=center>
<input type=button value="东 方" onClick="timeCheck(this.value, +300)" name="button1">
</td>
</tr>
<tr>
<td align=center>
<input type=button value="夏威夷" onClick="timeCheck(this.value, +600)" name="button">
</td>
<td align=center>
<input type=button value="墨西哥" onClick="timeCheck(this.value, +360)" name="button">
</td>
<td align=center>
<input type=button value="新德里" onClick="timeCheck(this.value, -330)" name="button">
</td>
</tr>
<tr>
<td align=center>
<input type=button value="北 京" onClick="timeCheck(this.value, -420)" name="button">
</td>
<td align=center>
<input type=button value="东 京" onClick="timeCheck(this.value, -540)" name="button">
</td>
<td align=center>
<input type=button value="伦 敦" onClick="timeCheck(this.value, +0)" name="button">
</td>
</tr>
</table>
</form>
0
评论
Comments
日志分类
首页
[138]
FLASH动画
[6]
图片处理
[4]
网页制作
[51]
办公软件
[2]
电脑网络
[21]
推荐软件
[18]
五彩缤纷
[23]
收藏夹
[6]
网站手记
[3]
培训日志
[4]