시간 설정, 시간 오차...

시간 설정, 시간 오차...

QA

시간 설정, 시간 오차...

본문

<?php if ($w == "u"): ?>
    <input type="hidden" name="wr_10" value="<?= $write['wr_10'] ?>">
<?php endif; ?>


<!-- 자폭 부분 -->
<?php if ($w == ""): ?>
    <tr>
        <td style='padding-left:50px; height:30px;'>· 자폭설정</td>
        <td>
            <input type="checkbox" name="bcheck" value="checkbox" onclick="chk1(this);">
            <select name="wr_10" style="FONT-SIZE: 9pt" onchange="doIt(this.value)">
                <option value="" selected>자폭안함</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+30 seconds')) ?>">30초 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+60 seconds')) ?>">60초 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+300 seconds')) ?>">5분 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+600 seconds')) ?>">10분 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+3600 seconds')) ?>">1시간 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+86400 seconds')) ?>">24시간 후</option>
            </select>
            <div id="mytext" class="redtext" style="display:inline" onclick="changeclass(this,'hi')">자동 폭파 사용 안함</div>
        </td>
    </tr>
    <tr><td colspan="2" height="1" bgcolor="#e7e7e7"></td></tr>
<?php endif; ?>

 

해당 소스는 게시물을 자폭하기 위한 소스입니다.

 

$BombDay = "<a href=\"javascript:alert('자폭 설정이 되어 있습니다.\\n자폭일 : ".$view[wr_10]."')\"><font color=red class=small>(자폭 설정이 작동 중입니다. 지정일: $bombdate)</font></a><br>";

 

보면 wr_10으로 시간을 저장하고 있는데...

 

문제는 시간 격차가 많이 발생합니다.

 

가령 30초를 선택하고, 제가 직접 새로고침을 연달아 누르고 있는 상태임에도

 

1분이 넘어서 작동하기도 하고 그러네요...

 

이 시간 격차 어떻게 수정하면 될까요?

 

참고로 php시간, 리눅스 시간 모두 서울라 맞춰둔 상태입니다..

 

이 질문에 댓글 쓰기 :

답변 2

자폭을 처리하는 부분의 소스가 있어야 할 것 같구요.

php 시간과 리눅스 시간의 오차는 없는지 실시간을 비교해보시구요.

 

30초를 선택하면 저장할때 시간 기준의 30초가 되야하지 않을까요?

지금은 설정하는 화면이 보여질때 기준이라 선택하고 저장하는데 몇초가 흐를수도 있겠습니다.

 

//자폭 시작
for ($i=0; $i<count($list); $i++) {
 $count_write = 0;
 $count_comment = 0;
 if($list[$i][wr_10]) {
  $g5[time_ymd] = date("Y-m-d H:i", G5_SERVER_TIME);
  $stoday = $g5[time_ymd];
  $bombdate = $list[$i][wr_10];
  $By = substr($bombdate,0,4);
  $Bm = substr($bombdate,5,2);
  $Bd = substr($bombdate,8,2) + 7;
  $Bh = substr($bombdate,11,2);
  $Bi = substr($bombdate,14,2);
  $bombdate7 = date("Y-m-d H:i",mktime($Bh,$Bi,0,$Bm,$Bd,$By) );
  $bombc = $list[$i][wr_id];
  if ($stoday > $bombdate7) {
  $sql = " select wr_id, mb_id, wr_is_comment from $write_table where wr_parent = '$bombc' order by wr_id ";
  $result = sql_query($sql);
  while ($row = sql_fetch_array($result))


이 부분인것 같네요. 소스는 이렇구요.

지금은

<?php
// 서버 시간을 변수에 할당
$serverTime = date('Y-m-d H:i:s', G5_SERVER_TIME);
?>

<div class="form-group">
    <label class="col-sm-2 control-label">자폭설정</label>
    <div class="col-sm-4">
        <div class="input-group input-group-sm">
            <input type="hidden" name="bcheck" value="checkbox" onclick="chk1(this);">
            <select name="wr_10" class="select-box form-control" onchange="doIt(this.value)">
                <option value="" selected>자동 폭파 안 함</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+30 seconds', G5_SERVER_TIME)) ?>">30초 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+60 seconds', G5_SERVER_TIME)) ?>">60초 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+300 seconds', G5_SERVER_TIME)) ?>">5분 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+600 seconds', G5_SERVER_TIME)) ?>">10분 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+3600 seconds', G5_SERVER_TIME)) ?>">1시간 후</option>
                <option value="<?= date('Y-m-d H:i:s', strtotime('+86400 seconds', G5_SERVER_TIME)) ?>">24시간 후</option>
            </select>
            <div id="mytext" class="disable-text" onclick="changeclass(this, '')">자동 폭파 사용 안 함</div>
        </div>
    </div>
</div>
<?php endif; ?>

이렇게 바꿨습니다. 그런데도 시간 격차가 벌어지네요.

리눅스 시간과 php시간은 서울로 맞춰서 같습니다 ㅠㅠ

$g5[time_ymd] = date("Y-m-d H:i", G5_SERVER_TIME);
  $stoday = $g5[time_ymd];
  $bombdate = $list[$i][wr_10];
  $By = substr($bombdate,0,4);
  $Bm = substr($bombdate,5,2);
  $Bd = substr($bombdate,8,2) + 7;
  $Bh = substr($bombdate,11,2);
  $Bi = substr($bombdate,14,2);
  $bombdate7 = date("Y-m-d H:i",mktime($Bh,$Bi,0,$Bm,$Bd,$By) );
  $bombc = $list[$i][wr_id];
  if ($stoday > $bombdate7) {

이 부분을 아래와 같이 수정하고 해보세요

$stoday = date("Y-m-d H:i:s", G5_SERVER_TIME);
$bombdate = $list[$i][wr_10];
if ($stoday > $bombdate) {

답변을 작성하시기 전에 로그인 해주세요.
전체 25
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT