<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Jasko Sample Script </TITLE>
<META NAME="Author" CONTENT="JASKO">
<META NAME="Keywords" CONTENT="javascript, 자바스크립트, 자바">
<META NAME="Description" CONTENT="자바스크립트 소스뱅크 - 자스코">
<!---- [1단계] 아래의 소스코드를 <HEAD>와 </HEAD> 사이에 붙여 넣으세요 ---->
<SCRIPT LANGUAGE="JavaScript">
<!--
function Calculate()
{
if(document.form1.switcher.value == "=>")
timeToHuman();
else if(document.form1.switcher.value == "<=")
humanToTime();
}
function timeToHuman()
{
var theDate = new Date(document.form1.timeStamp.value * 1000);
dateString = theDate.toGMTString();
arrDateStr = dateString.split(" ");
document.form1.inMon.value = getMonthNum(arrDateStr[2]);
document.form1.inDay.value = arrDateStr[1];
document.form1.inYear.value = arrDateStr[3];
document.form1.inHr.value = arrDateStr[4].substr(0,2);
document.form1.inMin.value = arrDateStr[4].substr(3,2);
document.form1.inSec.value = arrDateStr[4].substr(6,2);
}
function humanToTime()
{
var humDate = new Date(date.utc(document.form1.inYear.value,
(stripLeadingZeroes(document.form1.inMon.value)-1),
stripLeadingZeroes(document.form1.inDay.value),
stripLeadingZeroes(document.form1.inHr.value),
stripLeadingZeroes(document.form1.inMin.value),
stripLeadingZeroes(document.form1.inSec.value)));
document.form1.timeStamp.value = (humDate.getTime()/1000.0);
}
function pointRight()
{
document.form1.switcher.value="=>";
}
function pointLeft()
{
document.form1.switcher.value="<=";
}
function stripLeadingZeroes(input)
{
if((input.length > 1) && (input.substr(0,1) == "0"))
return input.substr(1);
else
return input;
}
function getMonthNum(abbMonth)
{
var arrMon = new Array("Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec");
for(i=0; i<arrMon.length; i++)
{
if(abbMonth == arrMon[i])
return i+1;
}
}
// -->
</script>
<!------------------------- 여기까지 ---------------------------------->
</HEAD>
<BODY>
<!---- [2단계] 아래의 코드를 <BODY> 태그와 </BODY> 태그안에 붙여 넣으세요 ---->
<form name=form1>
<table border=0>
<tr>
<th>유닉스 타임스탬프 값 (초) :</th>
<td valign=bottom rowspan=2>
<input type=button name=switcher value="변환하기" onClick="Calculate();"></td>
<th>년:</th>
<th> </th>
<th>월:</th>
<th> </th>
<th>일:</th>
<th> </th>
<th>시:</th>
<th> </th>
<th>분:</th>
<th> </th>
<th>초:</th>
<th> </th>
</tr>
<tr>
<td align=center><input type=text size=20 maxlength=11 name=timeStamp onKeyUp="pointRight();"></td>
<td><input type=text size=4 maxlength=4 name=inYear onKeyUp="pointLeft();"></td>
<th>/</th>
<td><input type=text size=4 maxlength=2 name=inMon onKeyUp="pointLeft();"></td>
<th>/</th>
<td><input type=text size=4 maxlength=2 name=inDay onKeyUp="pointLeft();"></td>
<th> </th>
<td><input type=text size=4 maxlength=2 name=inHr onKeyUp="pointLeft();"></td>
<th>:</th>
<td><input type=text size=4 maxlength=2 name=inMin onKeyUp="pointLeft();"></td>
<th>:</th>
<td><input type=text size=4 maxlength=2 name=inSec onKeyUp="pointLeft();"></td>
<th>GMT</th>
</tr>
</table>
</form>
<!------------------------- 여기까지 ---------------------------------->
</BODY>
</HTML>
http://oxtag.com/php/p/timestamp_change.php
<HTML>
<HEAD>
<TITLE> Jasko Sample Script </TITLE>
<META NAME="Author" CONTENT="JASKO">
<META NAME="Keywords" CONTENT="javascript, 자바스크립트, 자바">
<META NAME="Description" CONTENT="자바스크립트 소스뱅크 - 자스코">
<!---- [1단계] 아래의 소스코드를 <HEAD>와 </HEAD> 사이에 붙여 넣으세요 ---->
<SCRIPT LANGUAGE="JavaScript">
<!--
function Calculate()
{
if(document.form1.switcher.value == "=>")
timeToHuman();
else if(document.form1.switcher.value == "<=")
humanToTime();
}
function timeToHuman()
{
var theDate = new Date(document.form1.timeStamp.value * 1000);
dateString = theDate.toGMTString();
arrDateStr = dateString.split(" ");
document.form1.inMon.value = getMonthNum(arrDateStr[2]);
document.form1.inDay.value = arrDateStr[1];
document.form1.inYear.value = arrDateStr[3];
document.form1.inHr.value = arrDateStr[4].substr(0,2);
document.form1.inMin.value = arrDateStr[4].substr(3,2);
document.form1.inSec.value = arrDateStr[4].substr(6,2);
}
function humanToTime()
{
var humDate = new Date(date.utc(document.form1.inYear.value,
(stripLeadingZeroes(document.form1.inMon.value)-1),
stripLeadingZeroes(document.form1.inDay.value),
stripLeadingZeroes(document.form1.inHr.value),
stripLeadingZeroes(document.form1.inMin.value),
stripLeadingZeroes(document.form1.inSec.value)));
document.form1.timeStamp.value = (humDate.getTime()/1000.0);
}
function pointRight()
{
document.form1.switcher.value="=>";
}
function pointLeft()
{
document.form1.switcher.value="<=";
}
function stripLeadingZeroes(input)
{
if((input.length > 1) && (input.substr(0,1) == "0"))
return input.substr(1);
else
return input;
}
function getMonthNum(abbMonth)
{
var arrMon = new Array("Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec");
for(i=0; i<arrMon.length; i++)
{
if(abbMonth == arrMon[i])
return i+1;
}
}
// -->
</script>
<!------------------------- 여기까지 ---------------------------------->
</HEAD>
<BODY>
<!---- [2단계] 아래의 코드를 <BODY> 태그와 </BODY> 태그안에 붙여 넣으세요 ---->
<form name=form1>
<table border=0>
<tr>
<th>유닉스 타임스탬프 값 (초) :</th>
<td valign=bottom rowspan=2>
<input type=button name=switcher value="변환하기" onClick="Calculate();"></td>
<th>년:</th>
<th> </th>
<th>월:</th>
<th> </th>
<th>일:</th>
<th> </th>
<th>시:</th>
<th> </th>
<th>분:</th>
<th> </th>
<th>초:</th>
<th> </th>
</tr>
<tr>
<td align=center><input type=text size=20 maxlength=11 name=timeStamp onKeyUp="pointRight();"></td>
<td><input type=text size=4 maxlength=4 name=inYear onKeyUp="pointLeft();"></td>
<th>/</th>
<td><input type=text size=4 maxlength=2 name=inMon onKeyUp="pointLeft();"></td>
<th>/</th>
<td><input type=text size=4 maxlength=2 name=inDay onKeyUp="pointLeft();"></td>
<th> </th>
<td><input type=text size=4 maxlength=2 name=inHr onKeyUp="pointLeft();"></td>
<th>:</th>
<td><input type=text size=4 maxlength=2 name=inMin onKeyUp="pointLeft();"></td>
<th>:</th>
<td><input type=text size=4 maxlength=2 name=inSec onKeyUp="pointLeft();"></td>
<th>GMT</th>
</tr>
</table>
</form>
<!------------------------- 여기까지 ---------------------------------->
</BODY>
</HTML>
http://oxtag.com/php/p/timestamp_change.php
반응형
'인터넷정보' 카테고리의 다른 글
TEXTAREA 폼에서 탭키 입력하는 법 (0) | 2007.10.18 |
---|---|
여러 이미지 스크롤 (0) | 2007.10.18 |
여러 이미지 스크롤 (0) | 2007.10.18 |
포트리스 게임 (0) | 2007.10.18 |
포트리스 게임 (0) | 2007.10.18 |
유닉스 타임스탬프 값을 GMT 시간으로 바꾸어 보자 - 현재 시간으로.. (0) | 2007.10.18 |
Windows 원하는 시간에 자동 종료하기 - 타이머 (0) | 2007.10.18 |
Windows 원하는 시간에 자동 종료하기 - 타이머 (0) | 2007.10.18 |
웹 개발자들이 알아야 할 윈도우 XP SP2 변경점(팝업,액티브X) (0) | 2007.10.18 |
웹 개발자들이 알아야 할 윈도우 XP SP2 변경점(팝업,액티브X) (0) | 2007.10.18 |