자바스크립트 시간 표현 ㅜㅜ

· 15년 전 · 1629
자바스크립트로 카운트다운 숫자 내려가는걸 외국싸이트에서 퍼와서 넣었는데
시간이 서버시간으로 안나오고 캘리포니아 시간으로 나오는데 왜그런걸까요... ㅜㅜ

밑에는 구현법이고요. 그 밑이 코드입니다..

[code]
<script language="JavaScript">
TargetDate = "<?=date("m", $finishdate)?>/<?=date("d", $finishdate)?>/<?=date("Y", $finishdate)?> 12:00 PM";
BackColor = "333333";
ForeColor = "color: 3399ff; font-size:15pt;"
Font ="Arial";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%H%%:%%M%%:%%S%%";
FinishMessage = "00 : 00 : 00";
</script>
<script language="JavaScript" src="/countdown.js"></script>
[/code]

[code]

function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
s = "0" + s;
return "<b>" + s + "</b>";
}

function CountBack(secs) {
if (secs < 0) {
document.getElementById("cntdwn").innerHTML = FinishMessage;
return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,100));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
document.write("<span id='cntdwn' style='background-color:" + backcolor +
"; " + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);



[/code]

첨부파일

countdown.js (2.5 KB) 10회 2011-01-17 19:36
|
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
15년 전 조회 973
15년 전 조회 1,869
15년 전 조회 2,098
15년 전 조회 1,585
15년 전 조회 1,719
15년 전 조회 997
15년 전 조회 858
15년 전 조회 859
15년 전 조회 1,827
15년 전 조회 1,630
15년 전 조회 1,050
15년 전 조회 1,633
15년 전 조회 8,096
15년 전 조회 1,034
15년 전 조회 1,322
15년 전 조회 842
15년 전 조회 1,037
15년 전 조회 2,043
15년 전 조회 2,293
15년 전 조회 1,545