
function Demo() {
	yTime = new Date()   
	diff = yTime.getTime() - xTime.getTime()
	return(diff/1000)
}
//世界時間資料
var timeData = {
"亞洲(各國時間標准)": {   //東亞---------------------------------
"中國":["+0800","","北京,內蒙,西藏,新疆,福建,台-港-澳,遼寧,南沙"],
"馬來西亞，新加坡":["+0800","","吉隆坡,檳城,沙巴,馬六甲,砂撈越,新加坡"],
"文萊":["+0800","","斯里巴加灣市"],
"緬甸":["+0630","","仰光"],
"韓國，日本":["+0900","","漢城,東京,大阪,劄幌"],
"老撾，柬埔寨，印尼":["+0700","","萬象,金邊,雅加達"],
"蒙古":["+0800","03L03|09L03","烏蘭巴托,庫倫"],
"菲律賓":["+0800","04F53|10F53","馬尼拉"],
"俄羅斯(阿納德)":["+1300","03L03|10L03","阿納德爾河(注：本地時間)"],
"俄羅斯(堪察加)":["+1200","03L03|10L03","堪察加半島(注：本地時間)"],
"俄羅斯(馬加丹)":["+1100","03L03|10L03","馬加丹(注：本地時間)"],
"俄羅斯(海參崴)":["+1000","03L03|10L03","符拉迪沃斯托克[海參崴](注：本地時間)"],
"俄羅斯(雅庫茨克)":["+0900","03L03|10L03","雅庫茨克(注：本地時間)"],
"越南，泰國":["+0700","","河內,曼穀"],
//中東,南亞------------------------------------
"阿富汗":["+0430","","喀布爾"],
"孟加拉，不丹":["+0600","","達卡,廷布"],
"尼泊爾":["+0545","","加德滿都"],
"印度":["+0530","","新德里,孟買,加爾各答"],
"巴基斯坦":["+0500","","卡拉奇,伊斯蘭堡"],
"哈薩克斯坦":["+0600","","阿斯塔納,阿拉木圖"],
"塔吉克，烏茲別克":["+0500","","杜尚別,塔什幹"],
"土庫曼，喬治亞":["+0500","","阿什哈巴德,第比利斯"],
"斯里蘭卡":["+0600","","科倫坡"],
"伊朗":["+0330","0413|1013","德黑蘭"],
"伊拉克":["+0300","0413|1013","巴格達"],
"以色列，巴勒斯坦":["+0200","04F53|09F53","耶路撒冷"],
"沙特阿拉伯，卡塔爾":["+0300","","利雅得,多哈"],
"科威特，也門、巴林":["+0300","","科威特城,薩那,麥納麥"],
"黎巴嫩":["+0200","03L03|10L03","貝魯特"],
"敘利亞":["+0200","0413|1013","大馬士革"],
"土耳其":["+0200","","伊斯坦堡"],
"塞浦路斯，約旦":["+0200","","尼科西亞,安曼"],
"馬爾代夫":["+0500","","馬累"],
"阿拉伯，阿曼":["+0400","","聯合酋長國[阿布紮比],馬斯喀特"]
},
"國際日期變更線":{
"日期變更線(東半球)":["+1200","","國際日期變更線(西)"],
"日期變更線(西半球)":["-1200","","國際日期變更線(東)"]
},
"歐洲(各國時間標准)":{//北歐----------------------------------------------
"丹麥":["+0100","04F03|10L03","哥本哈根"],
"芬蘭":["+0200","03L01|10L01","赫爾辛基"],
"冰島":["+0000","","雷克雅未克"],
"瑞典":["+0100","03L01|10L01","斯德哥爾摩"],
"挪威，瑞士，斯洛伐克":["+0100","","奧斯陸,蘇黎世,布拉迪斯拉發"],
//中歐,東歐----------------------------------------
"俄羅斯(莫斯科)":["+0300","03L03|10L03","莫斯科,伏爾加格勒"],
"烏克蘭[基輔]":["+0200","","基輔"],
"烏克蘭(SFR)":["+0300","","辛菲羅波爾"],
"白俄羅斯":["+0200","03L03|10L03","明斯克"],
"亞美尼亞，阿塞拜疆":["+0400","","埃里溫,巴庫"],
"奧地利":["+0100","03L01|10L01","維也納"],
"捷克，匈牙利":["+0100","","布拉格,布達佩斯"],
"吉爾吉斯":["+0500","","比斯凱克"],
"拉脫維亞，立陶宛":["+0200","","里加,維爾紐斯"],
"摩爾多瓦，羅馬尼亞":["+0200","","基希納烏,布加勒斯特"],
"波蘭，摩納哥":["+0100","","華沙,摩納哥市"],
"德國，盧森堡":["+0100","03L01|10L01","柏林,波恩,盧森堡市"],//西歐-----
"法國，比利時，荷蘭":["+0100","03L01|10L01","巴黎,布魯塞爾,阿姆斯特丹"],
"英國，愛爾蘭":["+0000","03L01|10L01","倫敦,都柏林"],
"愛沙尼亞，保加利亞":["+0200","","塔林,索菲亞"],//南歐-------
"阿爾巴尼亞":["+0100","","地拉那"],
"希臘":["+0200","03L01|10L01","雅典"],
"羅馬教廷，馬耳他":["+0100","","梵蒂岡,瓦萊塔"],
"意大利，西班牙":["+0100","03L01|10L01","羅馬,馬德里"],
"葡萄牙":["+0000","03L01|10L01","里斯本"],
"斯洛文尼亞，聖馬利諾":["+0100","","盧布爾雅那,聖馬利諾"],
"南斯拉夫(塞)":["+0100","","貝爾格萊德"]
},
"北美洲(各國時間標准)":{//--------------------------------------------
"加拿大(NST)":["-0330","04F02|10L02","紐芬蘭,聖約翰,古斯灣"],
"加拿大(AST)":["-0400","04F02|10L02","冰河灣"],
"加拿大(EST)":["-0500","04F02|10L02","蒙特羅"],
"加拿大(PST)":["-0800","04F02|10L02","溫哥華"],
"美國(東岸)":["-0500","04F02|10L02","華盛頓,紐約"],
"美國(印第安納)":["-0500","","印第安納"],
"美國(西岸)":["-0800","04F02|10L02","舊金山,洛杉磯"],
"美國(阿拉斯加)":["-0900","","阿拉斯加,朱諾"],
"美加(中部)":["-0600","04F02|10L02","美國(芝加哥),加拿大(雷迦納,雨河鎮)"],
"美(丹佛)，加(MST)":["-0700","04F02|10L02","美(丹佛),加(印奴維特港,埃德蒙頓,道森河)"]
},
"南美洲(各國時間標准)":{//------------------------------------------
"玻利維亞，安提瓜島":["-0400","","拉巴斯,巴布達島,聖約翰,"],
"阿根廷":["-0300","","布宜諾斯艾利斯"],
"巴哈馬，哥倫比亞":["-0500","","拿騷,波哥大"],
"貝里斯，哥斯達黎加":["-0600","","貝里斯,聖何塞"],
"巴西，智利":["-0300","10F03|02L03","巴西利亞,里約熱內盧,聖地亞哥"],
"古巴":["-0500","0413|10L03","哈瓦那"],
"多米尼加":["-0400","","聖多明各,羅梭"],
"厄瓜多爾，尼加拉瓜":["-0500","","基多,馬那瓜"],
"秘魯，海地，巴拿馬":["-0500","","利馬,太子港,巴拿馬市,牙買加(金斯敦)"],
"薩爾瓦多，危地馬拉":["-0600","","聖薩爾瓦多,危地馬拉城"],
"福克蘭群島":["-0300","09F03|04F03","史丹利"],
"洪都拉斯":["-0600","","特古西加爾巴"],
"墨西哥":["-0700","","馬薩特蘭"],
"墨西哥(墨西哥)":["-0600","","墨西哥城"],
"墨西哥(蒂華納)":["-0800","","蒂華納"],
"巴拉圭":["-0400","10F03|02L03","亞松森"],
"聖基茨和尼維斯":["-0400","","巴斯特爾"],
"蘇里南，烏拉圭":["-0300","","帕拉馬里博,蒙得維的亞"],
"聖盧西亞，委內瑞拉":["-0400","","卡斯特里,加拉加斯"]
},
"非洲(各國時間標准)":{//----------------------------------------------
"中非，乍得，加蓬":["+0100","","班吉,恩賈梅納市,利伯維爾"],
"喀麥隆，剛果(布)":["+0100","","雅溫得,布拉柴維爾"],
"阿爾及利亞，突尼斯":["+0100","","阿爾及爾,突尼斯市"],
"安哥拉，貝南":["+0100","","羅安達,新港"],
"博茨瓦納，布隆迪":["+0200","","哈博羅內,布瓊布拉"],
"埃及":["+0200","04L53|09L43","開羅"],
"埃塞俄比亞":["+0300","","亞的斯亞貝巴"],
"岡比亞，象牙海岸":["+0000","","班珠爾,阿比讓,雅穆索戈"],
"利比里亞，摩洛哥":["+0000","","蒙羅維亞,卡薩布蘭卡"],
"馬里，多哥":["+0000","","巴馬科,洛美隆"],
"馬達加斯，肯尼亞":["+0300","","塔那那利佛,內羅畢"],
"馬拉維，萊索托":["+0200","","利隆圭,馬塞盧"],
"毛里求斯":["+0400","","路易港"],
"莫桑比克，盧旺達":["+0200","","馬普托,基加利"],
"納米比亞":["+0200","09F03|04F03","溫得和克"],
"尼日利亞，尼日爾":["+0100","","阿布賈,尼亞美"],
"聖多美，塞內加爾":["+0000","","聖多美,達卡爾"],
"索馬里，烏幹達":["+0300","","摩加迪沙,坎帕拉"],
"南非，蘇丹":["+0200","","開普敦,普利托里亞,喀土穆"],
"坦桑尼亞":["+0300","","達累斯薩拉姆"],
"津巴布韋，贊比亞":["+0200","","哈拉雷,盧薩卡"]
},
"大洋洲(各國時間標准)":{//----------------------------------------------
"澳大利(阿、達)":["+0930","10F03|03F03","阿得雷德,達爾文"],
"澳大利(布、荷、悉)":["+1000","10F03|03F03","布里斯班,荷伯特,悉尼"],
"澳大利(佩思)":["+0800","10F03|03F03","佩思"],
"埃尼威托克島":["-1200","","埃尼威托克島"],
"斐濟":["+1200","11F03|02L03","蘇瓦"],
"關島，巴布亞新幾內亞":["+1000","","阿加尼亞,莫爾斯比港"],
"夏威夷(美)，塔希提":["-1000","","檀香山,帕佩特"],
"基里巴斯":["+1100","","塔拉瓦"],
"瑙魯，馬紹爾":["+1200","","瑙魯(亞倫),馬紹爾群島(馬朱羅)"],
"密克羅尼西亞":["+1000","","帕利基爾"],
"中途島(美)，紐埃":["-1100","","中途島,紐埃(新)阿洛菲"],
"薩摩亞，西薩摩亞":["-1100","","[美]屬薩摩亞(帕果帕果港),西薩摩亞(阿皮亞)"],
"新克里多尼亞(法)":["+1100","","努美阿"],
"新西蘭":["+1200","10F03|04F63","奧克蘭"],
"新西蘭":["+1245","10F03|04F63","惠靈頓"],
"皮特克恩群島(英)":["-0830","","亞當斯敦"],
"玻利尼西亞(法)":["-1000","","巴比蒂,塔希提,庫克群島(新西蘭)"],
"所羅門群島":["+1100","","霍尼亞拉"],
"托克勞群島(新)":["-1100","","努庫諾努,法考福,阿塔富"],
"湯加":["+1300","10F63|04F63","努庫阿洛法"]
}};
// 世界時間計算
var OneHour = 60*60*1000;
var OneDay = OneHour*24;
function showUTC(objD) {
   var dn,s;
   var hh = objD.getUTCHours();
   var mm = objD.getUTCMinutes();
   var ss = objD.getUTCSeconds();
   var zo = objTimeZone[0]/100;
   var zoa =Math.floor(zo);   var zo2 =(zo-Math.floor(zo))*100;
   var zo3 =Math.round((1/60*zo2)*100)/100;
   var zo4 =zoa+zo3;var zo5 ='(東'+Math.abs(zo4)+'區)';
   if(zo4==0)zo5 ='(格林威治時)';if(zo4<0)zo5 ='(西'+Math.abs(zo4)+'區)';
   s ='<font color=#FF0000>'+objD.getUTCFullYear() + "-" + (objD.getUTCMonth() + 1) + "-" + objD.getUTCDate()+"  ";
   if(hh<10) hh = '0' + hh;
   if(mm<10) mm = '0' + mm;
   if(ss<10) ss = '0' + ss;
   s +=  hh + ":" + mm + ":" + ss+"</font>"+zo5;
   return(s);
}
//傳入時差字串, 返回偏移之正負毫秒
function parseOffset(s) {
   var sign,hh,mm,v;
   sign = s.substr(0,1)=='-'?-1:1;
   hh = Math.floor(s.substr(1,2));
   mm = Math.floor(s.substr(3,2));
   v = sign*(hh*60+mm)*60*1000;
   return(v);
}
//返回UTC日期控件 (年,月-1,第幾個星期幾,幾點)
function getWeekDay(y,m,nd,w,h){
   var d,d2,w1;
   if(nd>0){
      d = new Date(Date.UTC(y, m, 1));
      w1 = d.getUTCDay();
      d2 = new Date( d.getTime() + ((w<w1? w+7-w1 : w-w1 )+(nd-1)*7   )*OneDay + h*OneHour);
   }
   else {
      nd = Math.abs(nd);
      d = new Date( Date.UTC(y, m+1, 1)  - OneDay );
      w1 = d.getUTCDay();
      d2 = new Date( d.getTime() + (  (w>w1? w-7-w1 : w-w1 )-(nd-1)*7   )*OneDay + h*OneHour);
   }
   return(d2);
}
//傳入某時間值, 日光節約字串 返回 true 或 false
function isDaylightSaving(d,strDS) {
   if(strDS == '') return(false);
   var m1,n1,w1,t1;
   var m2,n2,w2,t2;
   with (Math){
      m1 = Math.floor(strDS.substr(0,2))-1;
      w1 = Math.floor(strDS.substr(3,1));
      t1 = Math.floor(strDS.substr(4,1));
      m2 = Math.floor(strDS.substr(6,2))-1;
      w2 = Math.floor(strDS.substr(9,1));
      t2 = Math.floor(strDS.substr(10,1));
   }
   switch(strDS.substr(2,1)){
      case 'F': n1=1; break;
      case 'L': n1=-1; break;
      default : n1=0; break;
   }
   switch(strDS.substr(8,1)){
      case 'F': n2=1; break;
      case 'L': n2=-1; break;
      default : n2=0; break;
   }
   var d1, d2, re;
   if(n1==0)
      d1 = new Date(Date.UTC(d.getUTCFullYear(), m1, Math.floor(strDS.substr(2,2)),t1));
   else
      d1 = getWeekDay(d.getUTCFullYear(),m1,n1,w1,t1);
   if(n2==0)
      d2 = new Date(Date.UTC(d.getUTCFullYear(), m2, Math.floor(strDS.substr(8,2)),t2));
   else
      d2 = getWeekDay(d.getUTCFullYear(),m2,n2,w2,t2);
   if(d2>d1)
      re = (d>d1 && d<d2)? true: false;
   else
      re = (d>d1 || d<d2)? true: false;
   return(re);
}
var isDS = false;
//計算全球時間
function getGlobeTime() {
   var d,s;
   d = new Date();
   d.setTime(d.getTime()+parseOffset(objTimeZone[0]));
   isDS=isDaylightSaving(d,objTimeZone[1]);
   if(isDS) d.setTime(d.getTime()+OneHour);
   return(showUTC(d));
}
var objTimeZone;
var objContinentMenu;
var objCountryMenu;
function tick5() {
   var today;
   today = new Date();
   //LocalTime.innerHTML = showLocale(today);
   GlobeTime.innerHTML = getGlobeTime();
   window.setTimeout("tick5()", 1000);
}
//指定自定索引時區
function setTZ(a,c){
   objContinentMenu.options[a].selected=true;
   chContinent();
   objCountryMenu.options[c].selected=true;
   chCountry();
}
//變更區域
function chContinent() {
   var key,i;
   continent = objContinentMenu.options[objContinentMenu.selectedIndex].text;
   for (var i = objCountryMenu.options.length-1; i >= 0; i--)
      objCountryMenu[0]=null;
   for (key in timeData[continent])
      objCountryMenu.options[objCountryMenu.options.length]=new Option(key);
   objCountryMenu.options[0].selected=true;
   chCountry();
}
//變更國家
function chCountry() {
   var txtContinent = objContinentMenu.options[objContinentMenu.selectedIndex].text;
   var txtCountry = objCountryMenu.options[objCountryMenu.selectedIndex].text;
   objTimeZone = timeData[txtContinent][txtCountry];
   getGlobeTime();
   City.innerHTML =(isDS==true?"<SPAN STYLE='font-size:11pt;font-family:Wingdings; color:Red;'>R</span>":'') + objTimeZone[2]; //首都
}
function getCookie(Name) {
   var search = Name + "=";
   if(document.cookie.length > 0) {
      offset = document.cookie.indexOf(search);
      if(offset != -1) {
         offset += search.length;
         end = document.cookie.indexOf(";", offset);
         if(end == -1) end = document.cookie.length;
         return unescape(document.cookie.substring(offset, end));
      }
      else return('');
   }
   else return('');
}
function initialize() {
   var key;
   objContinentMenu=document.WorldClock.continentMenu;
   objCountryMenu=document.WorldClock.countryMenu;
   for (key in timeData)
   objContinentMenu[objContinentMenu.length]=new Option(key);
   var TZ1 = getCookie('TZ1');
   var TZ2 = getCookie('TZ2');
   if(TZ1=='') {TZ1=0; TZ2=0;}
   setTZ(TZ1,TZ2);
   tick5(); 
}

應用方法：
<script language="JavaScript">  腳本代碼   </script>
或<SCRIPT src="腳本文件名.js"></SCRIPT>
註意initialize()要放在<BODY onLoad=initialize();>；我是沒有這樣放的。
我是這樣放的 var jsa='<SCRIPT language=JScript event=onload for=window>initialize();等等</SCRIPT>';
然後“jsa”放在“dw('</TBODY></table></TD>'+jsa);”

下面是“initialize()”要放在“<BODY onLoad=initialize();>；”的使用舉例


  <BODY onLoad=initialize();>
  <table width=763 align="center" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF8C1A">
<TR><TD>
  <table width=725 align="right" border="0" cellpadding="1" cellspacing="1" bordercolor="#FF8C1A" bgcolor="#FF8C1A">
  <TBODY bgcolor="#FFffff">
  <tr>
     <td height="100%" valign="top" bgcolor="#FFFFFF"><FORM name=WorldClock>
     <SELECT style="WIDTH: 135px;" onchange=chContinent() name=continentMenu>
        </SELECT><SELECT style="WIDTH: 139px;" onchange=chCountry() name=countryMenu>
         </SELECT><q id=GlobeTime></q><q id=City></q></TD></TR></FORM>
       </b></td></tr>
 </BODY></table>
</HTML>
