« RealPlayer for Linux | Main | MPlayre for Linux »

May 18, 2005

World Time for Javascript

仕事柄、ブラウザでワールドタイムが分かれば便利だなと思い、
ネット上を探してみました。
http://ask.jp/
なかなか良い検索結果と出会えました。

-----
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>World time</title>
<SCRIPT language="JavaScript">
<!--
_x=5
tz = new Array(_x)
tz[0] = 9 ;
tz[1] = 0 ;

day=new Array("日","月","火","水","木","金","土");

function Clock(){

for(i=0;i<_x;i++){
_now=new Date();
_now1=new Date();
_now1.setTime(_now.getTime() + (_now.getTimezoneOffset() + tz[i]*60) * 60 * 1000);

_Month =_now1.getMonth();
_Date =_now1.getDate();
_Hours =_now1.getHours();
_Minutes =_now1.getMinutes();
_Seconds =_now1.getSeconds();
_Day = day[_now1.getDay()];
if(_Hours <10){_Hours =" "+_Hours}
if(_Minutes<10){_Minutes=" "+_Minutes}
if(_Seconds<10){_Seconds=" "+_Seconds}

document.forms[0].elements[i*3+1].value=_Month+"月"+_Date+"日("+_Day+")";
document.forms[0].elements[i*3+2].value=_Hours+"時"+_Minutes+"分"+_Seconds+"秒";
}
setTimeout(" Clock()",1000);
}

function ChangeCity(x){return document.forms[0].elements[x*3].options[document.forms[0].elements[x*3].selectedIndex].value;}

// -->
</SCRIPT>

<style>
<!--
td { height:40px}
input ,select { font: bold 100%}

-->
</style>
</HEAD>

<BODY onLoad="for(i=2;i<_x;i++){tz[i]=ChangeCity(i)};Clock()">
World Times
<table>
<form>
<tr>
<td><input value="日本標準時" size="14"></td>
<td><input size="15"> <input size="15"></td>
<tr>
<td><input value="グリニッジ" size="14"></td>

<td><input size="15"> <input size="15"></td>
</tr>
<td>
<select onChange="tz[2]=ChangeCity(2)">
<option value=-10 >Hawai
<option value= -8 >Los Angeles
<option value= -5 >New York
<option value= 0 >London
<option value= 1 >Pari
<option value= 1 selected>Berlin
<option value= 8 >Hong Kong
<option value= 8 >Singapore
</select></td>
<td><input size="15"> <input size="15"></td>

<tr>
<td>
<select onChange="tz[3]=ChangeCity(3)">
<option value=-10 >Hawai
<option value= -8 >Los Angeles
<option value= -5 >New York
<option value= 0 >London
<option value= 1 >Pari
<option value= 1 >Berlin
<option value= 8 >Hong Kong
<option value= 8 selected>Singapore
</select></td>
<td><input size="15"> <input size="15"></td>

</tr>
<tr>
<td>
<select onChange="tz[4]=ChangeCity(4)">
<option value=-10 >Hawai
<option value= -8 >Los Angeles
<option value= -5 selected>New York
<option value= 0 >London
<option value= 1 >Pari
<option value= 1 >Berlin
<option value= 8 >Hong Kong
<option value= 8 >Singapore
</select></td>

<td><input size="15"> <input size="15"></td>
</tr>
</table>

</BODY>
</HTML>
-----

ブラウザで”Javascript”を”可”にして開いてみてください。
なお、不具合など起きた場合、一切責任は追いかねますのであしからず。

|

« RealPlayer for Linux | Main | MPlayre for Linux »

Script」カテゴリの記事

Comments

Post a comment



(Not displayed with comment.)


Comments are moderated, and will not appear on this weblog until the author has approved them.



TrackBack


Listed below are links to weblogs that reference World Time for Javascript:

« RealPlayer for Linux | Main | MPlayre for Linux »