世界各国时间代码,留着备用!

本文提供了一个简单的网页代码示例,用于实时显示北京、伦敦、纽约、芝加哥和东京等世界主要城市的当前时间,通过JavaScript定时更新各城市的时间,便于进行国际间的时差对比。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

世界各国时间代码,留着备用!代码如下:

<!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>
<style type=”text/css”>
*{margin:0px;padding:0px; font-size:12px;}
</style>
</head>

<body>
<div style=”width:1000px;line-height:30px;margin:0 auto; background:#ccc;”>
<TABLE height=15 cellSpacing=0 cellPadding=0 width=”96%” border=0>
<TR vAlign=top>
<TD vAlign=center nowrap class=”font1″>北京时间[<SPAN id=beijing></SPAN>]</TD>
<TD vAlign=center nowrap class=”font1″>伦敦时间[<SPAN id=london></SPAN>]</TD>
<TD vAlign=center nowrap class=”font1″>纽约时间[<SPAN id=newyork></SPAN>]</TD>
<TD vAlign=center nowrap class=”font1″>芝加哥时间[<SPAN id=chicago></SPAN>]</TD>
<TD vAlign=center nowrap class=”font1″>东京时间[<SPAN id=tokyo></SPAN>]</TD>
</TR>
</TABLE>
<SCRIPT language=javascript type=text/javascript>
//<![CDATA[
function time_rota()
{
var now;
var h,m,s;
now = new Date();
h=now.getHours();
m=now.getMinutes();
s=now.getSeconds();
h=((h < 10) ? "0" : "") + h;
m=((m < 10) ? "0" : "") + m;
s=((s < 10) ? "0" : "") + s;
document.all.beijing.innerHTML = h+":"+m+":"+s;
setTimeout("time_rota()", 1000);
}
time_rota();
function time_rota1()
{
var now;
var h,m,s;
now = new Date();
h=now.getUTCHours();
h -= -0;
if(h<0)
{h += 24;}
m=now.getUTCMinutes();
s=now.getUTCSeconds();
h=((h < 10) ? "0" : "") + h;
m=((m < 10) ? "0" : "") + m;
s=((s < 10) ? "0" : "") + s;
document.all.london.innerHTML = h+":"+m+":"+s;
setTimeout("time_rota1()", 1000);
}
time_rota1();
function time_rota2()
{
var now;
var h,m,s;
now = new Date();
h=now.getHours();
h -= 13;
if(h<0)
{h += 24;}
m=now.getMinutes();
s=now.getSeconds();
h=((h < 10) ? "0" : "") + h;
m=((m < 10) ? "0" : "") + m;
s=((s < 10) ? "0" : "") + s;

document.all.newyork.innerHTML = h+":"+m+":"+s;
setTimeout("time_rota2()", 1000);
}
time_rota2();
function time_rota3()
{
var now;
var h,m,s;
now = new Date();
h=now.getUTCHours();
h -= -9;
if(h<=0)
{h += 24;}
m=now.getUTCMinutes();
s=now.getUTCSeconds();
h=((h < 10) ? "0" : "") + h;
m=((m < 10) ? "0" : "") + m;
s=((s < 10) ? "0" : "") + s;
document.all.tokyo.innerHTML = h+":"+m+":"+s;
setTimeout("time_rota3()", 1000);
}
time_rota3();
function time_rota4()
{
var now;
var h,m,s;
now = new Date();
h=now.getUTCHours();
h -= 6;
if(h<=0)
{h += 24;}
m=now.getUTCMinutes();
s=now.getUTCSeconds();
h=((h < 10) ? "0" : "") + h;
m=((m < 10) ? "0" : "") + m;
s=((s < 10) ? "0" : "") + s;
document.all.chicago.innerHTML = h+":"+m+":"+s;
setTimeout("time_rota4()", 1000);
}
time_rota4();
//]]>
</SCRIPT>
</div>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值