您的位置:首页 > Web前端 > JavaScript

几个国家时间同步动态显示js代码

2011-11-07 18:36 417 查看
几个国时间js同步动态显示,对于做企业网站的朋友相信用的到,特别是做英文网站的朋友,加上这一段代码会给你的网站增色不少!

<!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=utf-8" />

<title>无标题文档</title>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<br>

<form name="clock">

<table align="center" cellpadding="0" cellspacing="0" height="253" bordercolordark="white"

bordercolorlight="black" background="worldmap.jpg" width="680" style="font-size: 9pt">

<tr>

<td height="34" align="center">

<font color="#FF6633"><strong>世界时钟</strong></font>

</td>

</tr>

<tr>

<td align="center">

北京时间:

<input type="text" size="8" name="local">

</td>

</tr>

<tr>

<td width="877" height="199" align="center" valign="top">

<table width="680" border="1" cellspacing="0" bordercolorlight="black" bordercolordark="white" style="font-size: 9pt">

<tr bgcolor="#CCCCCC">

<td width="58" height="24" align="center">

夏威夷

</td>

<td width="62" align="center">

阿拉斯加

</td>

<td width="71" align="center">

太平洋时间

</td>

<td width="90" align="center">

美国山地时间

</td>

<td width="85" align="center">

美国中部时间

</td>

<td width="82" align="center">

美国东部时间

</td>

<td width="65" align="center">

大西洋时间

</td>

<td width="56" align="center">

巴西

</td>

<td width="73" align="center">

大西洋-中部

</td>

</tr>

<tr>

<td width="58" align="center">

GMT-10

</td>

<td width="62" align="center">

GMT-9

</td>

<td width="71" align="center">

GMT-8

</td>

<td width="90" align="center">

GMT-7

</td>

<td width="85" align="center">

GMT-6

</td>

<td width="82" align="center">

GMT-5

</td>

<td width="65" align="center">

GMT-4

</td>

<td width="56" align="center">

GMT-3

</td>

<td width="73" align="center">

GMT-2

</td>

</tr>

<tr>

<td width="58" align="center">

<input type="text" size="8" name="Hawaii">

</td>

<td width="62" align="center">

<input type="text" size="8" name="alaska">

</td>

<td width="71" align="center">

<input type="text" size="8" name="pacif">

</td>

<td width="90" align="center">

<input type="text" size="8" name="mount">

</td>

<td width="85" align="center">

<input type="text" size="8" name="center">

</td>

<td width="82" align="center">

<input type="text" size="8" name="east">

</td>

<td width="65" align="center">

<input type="text" size="8" name="atl">

</td>

<td width="56" align="center">

<input type="text" size="8" name="bra">

</td>

<td width="73" align="center">

<input type="text" size="8" name="mid">

</td>

</tr>

<tr bgcolor="#999999">

<td height="3" colspan="9" align="center">

<br>

<br>

<br>

</td>

</tr>

<tr bgcolor="#CCCCCC">

<td width="58" height="20" align="center">

伦敦

</td>

<td width="62" align="center">

柏林

</td>

<td width="71" align="center">

开罗

</td>

<td width="90" align="center">

莫斯科

</td>

<td width="85" align="center">

新德里

</td>

<td width="82" align="center">

曼谷

</td>

<td width="65" align="center">

香港

</td>

<td width="56" align="center">

东京

</td>

<td width="73" align="center">

悉尼

</td>

</tr>

<tr>

<td width="58" align="center">

GMT

</td>

<td width="62" align="center">

GMT +1

</td>

<td width="71" align="center">

GMT +2

</td>

<td width="90" align="center">

GMT +3

</td>

<td width="85" align="center">

GMT +5

</td>

<td width="82" align="center">

GMT +7

</td>

<td width="65" align="center">

GMT +8

</td>

<td width="56" align="center">

GMT +9

</td>

<td width="73" align="center">

GMT +10

</td>

</tr>

<tr>

<td width="58">

<input type="text" size="8" name="_GMT">

</td>

<td width="62">

<input type="text" size="8" name="rome">

</td>

<td width="71">

<input type="text" size="8" name="Israel">

</td>

<td width="90">

<input type="text" size="8" name="msw">

</td>

<td width="85">

<input type="text" size="8" name="del">

</td>

<td width="82">

<input type="text" size="8" name="kok">

</td>

<td width="65">

<input type="text" size="8" name="ho">

</td>

<td width="56">

<input type="text" size="8" name="tky">

</td>

<td width="73">

<input type="text" size="8" name="sdn">

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td width="877" height="2" align="center">

</td>

</tr>

</table>

北京时间:<input type="text" size="8" name="beijing">

首尔时间:<input type="text" size="8" name="shoer">

伦敦时间:<input type="text" size="8" name="lundun">

纽约时间:<input type="text" size="8" name="niuyue">

悉尼时间:<input type="text" size="8" name="xini">

莫斯科时间:<input type="text" size="8" name="mosike">

</form>

<script language="JavaScript">

<!-- Begin

function GetTime() {

var dt = new Date();

var def = dt.getTimezoneOffset() / 60;

var gmt = (dt.getHours() + def);

document.clock.local.value = (IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var ending = ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds());

var rome = check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));

document.clock.rome.value = (IfZero(rome) + ending);

var isr = check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));

document.clock.Israel.value = (IfZero(isr) + ending);

var msw = check24(((gmt + 3) > 24) ? ((gmt + 3) - 24) : (gmt + 3));

document.clock.msw.value = (IfZero(msw) + ending);

var del = check24(((gmt + 5) > 24) ? ((gmt + 5) - 24) : (gmt + 5));

document.clock.del.value = (IfZero(del) + ending);

var kok = check24(((gmt + 7) > 24) ? ((gmt + 7) - 24) : (gmt + 7));

document.clock.kok.value = (IfZero(kok) + ending);

var ho = check24(((gmt + 8) > 24) ? ((gmt + 8) - 24) : (gmt + 8));

document.clock.ho.value = (IfZero(ho) + ending);

var tky = check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));

document.clock.tky.value = (IfZero(tky) + ending);

var sdn = check24(((gmt + 10) > 24) ? ((gmt + 10) - 24) : (gmt + 10));

document.clock.sdn.value = (IfZero(sdn) + ending);

var _GMT = check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));

document.clock._GMT.value = (IfZero(_GMT) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var haw = check24(((gmt + (24 - 10)) > 24) ? ((gmt + (24 - 10)) - 24) : (gmt + (24 - 10)));

document.clock.Hawaii.value = (IfZero(haw) + ending);

var ala = check24(((gmt + (24 - 9)) > 24) ? ((gmt + (24 - 9)) - 24) : (gmt + (24 - 9)));

document.clock.alaska.value = (IfZero(ala) + ending);

var pacif = check24(((gmt + (24 - 8)) >= 24) ? ((gmt + (24 - 8)) - 24) : (gmt + (24 - 8)));

document.clock.pacif.value = (IfZero(pacif) + ending);

var mount = check24(((gmt + (24 - 7)) > 24) ? ((gmt + (24 - 7)) - 24) : (gmt + (24 - 7)));

document.clock.mount.value = (IfZero(mount) + ending);

var center = check24(((gmt + (24 - 6)) > 24) ? ((gmt + (24 - 6)) - 24) : (gmt + (24 - 6)));

document.clock.center.value = (IfZero(center) + ending);

var east = check24(((gmt + (24 - 5)) > 24) ? ((gmt + (24 - 5)) - 24) : (gmt + (24 - 5)));

document.clock.east.value = (IfZero(east) + ending);

var atl = check24(((gmt + (24 - 4)) > 24) ? ((gmt + (24 - 4)) - 24) : (gmt + (24 - 4)));

document.clock.atl.value = (IfZero(atl) + ending);

var bra = check24(((gmt + (24 - 3)) > 24) ? ((gmt + (24 - 3)) - 24) : (gmt + (24 - 3)));

bra = (bra >= 24) ? bra - 24 : bra;

document.clock.bra.value = (IfZero(bra) + ending);

var mid = check24(((gmt + (24 - 2)) > 24) ? ((gmt + (24 - 2)) - 24) : (gmt + (24 - 2)));

mid = (mid >= 24) ? mid - 24 : mid;

document.clock.mid.value = (IfZero(mid) + ending);

document.clock.beijing.value = (IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var shoer = check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));

document.clock.shoer.value = (IfZero(shoer) + ending);

var lundun = check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));

document.clock.lundun.value = (IfZero(lundun) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var niuyue = check24(((gmt + (24 - 5)) > 24) ? ((gmt + (24 - 5)) - 24) : (gmt + (24 - 5)));

document.clock.niuyue.value = (IfZero(niuyue) + ending);

var xini = check24(((gmt + 10) > 24) ? ((gmt + 10) - 24) : (gmt + 10));

document.clock.xini.value = (IfZero(xini) + ending);

var mosike = check24(((gmt + 3) > 24) ? ((gmt + 3) - 24) : (gmt + 3));

document.clock.mosike.value = (IfZero(mosike) + ending);

setTimeout("GetTime()", 1000);

}

function IfZero(num) {

return ((num <= 9) ? ("0" + num) : num);

}

function check24(hour) {

return (hour >= 24) ? hour - 24 : hour;

}

javascript: GetTime();

// End -->

</script>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: