客户端时间脚本(中国、美国时间),摘抄部分代码如下:
<SCRIPT language="JavaScript">
var ctimer;
function init(){
if (document.all){
settimes();
}
}
function settimes(){
var time= new Date();
hours= time.getHours();
hourUSA = time.getHours()-16;
mins= time.getMinutes();
secs= time.getSeconds();
if (hours<10)
hours="0"+hours;
if (hourUSA<0)
hourUSA=hourUSA+24;
if (hourUSA<10)
hourUSA="0"+hourUSA;
if(mins<10)
mins="0"+mins;
if (secs<10)
secs="0"+secs;
tim1.innerHTML="CHN "+hours+":"+mins+":"+secs
tim2.innerHTML="USA "+hourUSA+":"+mins+":"+secs
ctimer=setTimeout('settimes()',960);
}
</SCRIPT>
var ctimer;
function init(){
if (document.all){
settimes();
}
}
function settimes(){
var time= new Date();
hours= time.getHours();
hourUSA = time.getHours()-16;
mins= time.getMinutes();
secs= time.getSeconds();
if (hours<10)
hours="0"+hours;
if (hourUSA<0)
hourUSA=hourUSA+24;
if (hourUSA<10)
hourUSA="0"+hourUSA;
if(mins<10)
mins="0"+mins;
if (secs<10)
secs="0"+secs;
tim1.innerHTML="CHN "+hours+":"+mins+":"+secs
tim2.innerHTML="USA "+hourUSA+":"+mins+":"+secs
ctimer=setTimeout('settimes()',960);
}
</SCRIPT>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" onLoad="javascript:init();">
<table>
<tr>
<td>
<DIV class="time" id="tim1" style="LEFT: 870px; WIDTH: 96px; POSITION: absolute; TOP: 0px; HEIGHT: 5px"><FONT face="Times New Roman, Times, serif"></FONT></DIV>
<div Id="tim2" Style="LEFT:870px; WIDTH:96px; POSITION:absolute; TOP:15px; HEIGHT:5px"
class="time"><FONT face="Arial, Helvetica, sans-serif"></FONT></div>
</td>
</tr>
</table>
</BODY>
<table>
<tr>
<td>
<DIV class="time" id="tim1" style="LEFT: 870px; WIDTH: 96px; POSITION: absolute; TOP: 0px; HEIGHT: 5px"><FONT face="Times New Roman, Times, serif"></FONT></DIV>
<div Id="tim2" Style="LEFT:870px; WIDTH:96px; POSITION:absolute; TOP:15px; HEIGHT:5px"
class="time"><FONT face="Arial, Helvetica, sans-serif"></FONT></div>
</td>
</tr>
</table>
</BODY>