/**********************************************
남은시간 가져오기
09:00 ~ 11:00 사이가 이벤트라는군
***********************************************/
java.util.Calendar cal = java.util.Calendar.getInstance(new Locale("Korean", "Korea"));
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
double remain_day = 0;
long remain_time = 0;
int day = 0;
int hh = 0;
int mm = 0;
int ss = 0;
// 현재시간
long l_currtime = cal.getTime().getTime();
// 시작시간
java.util.Date s_time = sdf.parse("20050617090000");
cal.setTime(s_time);
java.sql.Date ss_date = new java.sql.Date(cal.getTime().getTime());
long l_s_time = ss_date.getTime();
// 종료시간
java.util.Date e_time = sdf.parse("20050617230000");
cal.setTime(e_time);
java.sql.Date ee_date = new java.sql.Date(cal.getTime().getTime());
long l_e_time = ee_date.getTime();
// 남은시간
double d_remain_time = (double)(l_e_time - l_currtime) /24/60/60/1000 ;
if ( l_currtime > l_s_time && d_remain_time > 0 )
{
day = (int)(d_remain_time); // 일자
remain_day = ( d_remain_time - (double)day ) * 24;
hh = (int)(remain_day); // 시간
remain_day = ( remain_day - (double)hh ) * 60;
mm = (int)(remain_day); // 분
remain_day = ( remain_day - (double)mm ) * 60;
ss = (int)(remain_day); // 초
}
out.println("day : " + day + "<br>");
out.println("hh : " + hh + "<br>");
out.println("mm : " + mm + "<br>");
out.println("ss : " + ss + "<br>");
==================================================================================
<script language="JavaScript">
<!--
var NewTime;
var intNew, intNow;
var strTime, strNow;
var intExtend, strStatus;
var remainTxt
isNS = ((navigator.appName == "Netscape") && !(ie4 || docom));
//version = parseInt(navigator.appVersion);
if (isNS) {
gLayerRef="document.layers";
gStyleSwitch="";
window.captureEvents(Event.RESIZE)
window.onresize = fixResize;
}else{
gLayerRef="document.all";
gStyleSwitch=".style";
}
function changeImage(imageUrl)
{
if (document.images.middleImage)
document.images.middleImage.src = imageUrl;
}
function InitTime(dd, hh, mi, ss)
{
if ( dd == 0 && hh == 0 && mi == 0 && ss == 0 )
{
remain_time.innerHTML = "경매마감";
return;
}
/*
if(dd > 28){
remainTxt.value = "";
return;
}
*/
dd = dd + 1;
NewTime = new Date(2000,1,dd,hh,mi,ss);
TimeRoutine();
}
function TimeRoutine()
{
intNew = NewTime.getSeconds() - 1;
NewTime.setSeconds(intNew);
if (NewTime.getMonth()==0
&& NewTime.getDate() == 31
&& NewTime.getHours() == 23
&& NewTime.getMinutes() == 59
&& NewTime.getSeconds() == 59)
{
document.location.reload();
return;
}
StatusClock();
}
function StatusClock()
{
strTime = "";
if ( NewTime.getMonth() != 1 )
{
strTime = strTime + eval(NewTime.getMonth()-1) + '개월 ';
}
if ( NewTime.getDate() != 1 )
{
strTime = strTime + eval(NewTime.getDate()-1) + '일 ';
}
strTime = strTime
+ NewTime.getHours()
+ '시간 '
+ NewTime.getMinutes()
+ '분 '
+ NewTime.getSeconds()
+ '초';
remain_time.innerHTML = strTime;
setTimeout("TimeRoutine()", 1000);
}
</script>
<script language="JavaScript">
<!--
InitTime(<%= day %>, <%= hh %>, <%= mm %>, <%= ss %>);
//-->
</script>