PHP & Others

경매 남은시간 소스

페이지 정보

본문

소스

<?php
/**
* ============================================================================================
* 남은시간 구하기
* --------------------------------------------------------------------------------------------
* @int mktime (int hour, int minute, int second, int month, int day, int year [, int is_dst]);
* @mktime (0,0,0,12,32,1997));
* =============================================================================================
**/

// 경매시작시간
$Stime[year] = "2004";
$Stime[month] = "1";
$Stime[day] = "1";
$Stime[hour] = "6";
$Stime[minute] = "10";
$Stime[second] = "0";
$StartTime=mktime($Stime[hour],$Stime[minute],$Stime[second],$Stime[month],$Stime[day],$Stime[year]);

// 경매종료시간
$Etime[year] = "2004";
$Etime[month] = "1";
$Etime[day] = "31";
$Etime[hour] = "19";
$Etime[minute] = "10";
$Etime[second] = "0";

// 종료시간의 타임스템프값 생성
$date1=mktime($Etime[hour],$Etime[minute],$Etime[second],$Etime[month],$Etime[day],$Etime[year]);
$date2=time();

$total_secs=abs($date1-$date2);
$diff_in_days = floor($total_secs / 86400);
$rest_hours = $total_secs % 86400;
$diff_in_hours = floor($rest_hours / 3600);
$rest_mins = $rest_hours % 3600;
$diff_in_mins = floor($rest_mins / 60);
$diff_in_secs = floor($rest_mins % 60);
$time_diff = $diff_in_days ."일".$diff_in_hours ."시간".$diff_in_mins ."분".$diff_in_secs ."초";

?>

<HTML>
<HEAD>
<TITLE>TIME SCRIPT</TITLE>
<style type='text/css'>
<!--
body,table,tr,th,td{font-size:10pt;font-family:굴림}
-->
</style>

<SCRIPT LANGUAGE='JavaScript'>
<!--
function Timer(diff_in_secs, diff_in_mins, diff_in_hours, diff_in_days)
{
day=diff_in_days;
hour=diff_in_hours;
min=diff_in_mins;
sec=diff_in_secs;
Timer1();
}

function Validtime() {
count.innerHTML = '<font color=red>경매가 종료되었습니다.</font>';
document.timer.checkval.value=0;
}

function Timer1()
{
sec-=1;
if(sec == -1){
sec = 59;
min = min-1;
}

if(min == -1) {
min=59;
hour = hour-1;
}

if(hour == -1){
hour = 23;
day = day-1;
}

if(sec == 0 && min == 0 && hour == 0 && day == 0){
count.innerHTML = '<font color=red>경매가 종료되었습니다.</font>';
document.timer.checkval.value=0;
return;
}
count.innerHTML = day + '일 ' + hour + '시간 ' + min + '분 ' + sec + '초 ';
window.setTimeout('Timer1()',1000);
}

function MyReg()
{
var f=document.timer;
if(f.checkval.value == 0) {
alert('공동구매가 종료되었습니다');
} else {
alert('공동구매가 진행중입니다');
}
}
-->
</SCRIPT>
<?php
if(($date1-$date2)>0) {
echo "<body onload='Timer($diff_in_secs, $diff_in_mins, $diff_in_hours, $diff_in_days)'>";
} else {
echo "<body onload='Validtime()'>";
}
?>

</head>

<BR>


<TABLE width="780" cellpadding=0 cellspacing=0 border=0 bgcolor="white" align="center" style="border-width:1; border-color:silver; border-style:none;">
<form name="timer">
<TR>
<TD>
<TABLE width="100%" border="1">
<TR height=28>
<TD width=85 align=center bgcolor=eeeeee>경매기간</TD>
<TD width=305> 
<?php
echo date("Y/m/d/ H:i:s",$StartTime);
echo "  ~  ";
echo date("Y/m/d/ H:i:s",$date1);
?>
</TD>
<TD width=85 align=center bgcolor=eeeeee>시작가</TD>
<TD width=305>1,000원
<input type="hidden" name="checkval" value="1">
</TD>
</TR>
<TR height=28>
<TD align=center bgcolor=eeeeee>남은시간</TD>
<TD> </TD>
<TD width=85 align=center bgcolor=eeeeee>현재가</TD>
<TD><font color="red">150,000원</font></TD>
</TR>
</TABLE>
</td>
</tr>
</table>

<TABLE width='780' border='1' align=center>
<TR height=300>
<TD bgcolor=ffffff align=center>좋은물건 떠리요!</TD>
</TR>
<tr>
<td align=right height=28><input type=button value='구매하기' onclick="MyReg();"></td>
</tr>
</form>
</TABLE>


</body>
</html>

관련자료

등록된 댓글이 없습니다.
Today's proverb
지식에 투자하는 것이 가장 이윤이 높다. (프랭클린)