자바스크립트 시간 표현 ㅜㅜ
자바스크립트로 카운트다운 숫자 내려가는걸 외국싸이트에서 퍼와서 넣었는데
시간이 서버시간으로 안나오고 캘리포니아 시간으로 나오는데 왜그런걸까요... ㅜㅜ
밑에는 구현법이고요. 그 밑이 코드입니다..
[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]
시간이 서버시간으로 안나오고 캘리포니아 시간으로 나오는데 왜그런걸까요... ㅜㅜ
밑에는 구현법이고요. 그 밑이 코드입니다..
[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]
게시판 목록
그누4 질문답변
그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.
기존 게시물은 열람만 가능합니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 66414 |
|
11년 전 | 3681 | |
| 66413 | 11년 전 | 3395 | ||
| 66412 |
kimch
|
11년 전 | 3131 | |
| 66411 |
포도주스와
|
11년 전 | 4398 | |
| 66410 | 11년 전 | 2611 | ||
| 66409 |
알지오공유
|
11년 전 | 5085 | |
| 66408 | 11년 전 | 4321 | ||
| 66407 |
알지오공유
|
11년 전 | 2907 | |
| 66406 |
Header
|
11년 전 | 2512 | |
| 66405 |
fancytank
|
11년 전 | 2261 | |
| 66404 | 11년 전 | 2450 | ||
| 66403 |
|
11년 전 | 3079 | |
| 66402 | 11년 전 | 4295 | ||
| 66401 | 11년 전 | 3308 | ||
| 66400 |
kimch
|
11년 전 | 2900 | |
| 66399 | 11년 전 | 2137 | ||
| 66398 |
열라뽕똬이
|
11년 전 | 2345 | |
| 66397 | 11년 전 | 3898 | ||
| 66396 |
안드로메달
|
11년 전 | 2404 | |
| 66395 |
그누초보님
|
11년 전 | 3473 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기