전체최신글에서 코멘트(댓글) 시간표기하는 방법을 문의합니다

전체최신글에서 코멘트(댓글) 시간표기하는 방법을 문의합니다

QA

전체최신글에서 코멘트(댓글) 시간표기하는 방법을 문의합니다

본문

안녕하세요? 

 

보들이윤님이 알려주신 방법인데...보들이윤님~ 죄송합니다.

 

제가 적용을 잘못해서인지 자정이 넘어가도 글쓴 후 24시간 이내에는 '몇 시간 전' 이렇게 출력이 되어야 하는데

자정이 넘어가니까 글쓴 후 24시간 이내인데도 '2017-01-24' 이렇게 날짜로 출력이 되어버리네요~

 

if($list[$i][wr_comment] >= date("Y-m-d H:i:s", G5_SERVER_TIME - (24 * 3600))) // 코멘트가 24시간 이내이면

  echo $list[$i]['datetime3'];

elseif($list[$i][wr_comment] < date("Y-m-d H:i:s", G5_SERVER_TIME - (24 * 3600))) // 코멘트가 24시간 이후이면

  echo $list[$i]['datetime3'];

else

  echo $list[$i]['datetime3'];

 

전체최신글에서 원글 리스트는 자정이 넘어가도 글쓴 후 24시간 이내에는 '몇 시간 전' 이렇게 출력이 되는데 

코멘트(댓글) 리스트만 글쓴 후 24시간 이내인데도 '2017-01-24' 이렇게 날짜로 출력이 됩니다.

 

참! 어렵네요~

짜집퍼라...보름 정도 이리저리해도 해결을 못하고 있습니다...ㅜㅜ

 

새해 복 많이 받으시고 항상 건강하십시오~^^)

감사합니다.

이 질문에 댓글 쓰기 :

답변 2

조건이 잘못된듯합니다.

if($list[$i][wr_comment] >= date("Y-m-d H:i:s", G5_SERVER_TIME - (24 * 3600))) 

$list[$i][wr_comment] 는 시간이 들어있는것이아니라 

숫자 0,1,2,3등 코멘트의 갯수가 들어가는 필드이고

if 조건문에서 시간을 비교하는데

시간과 시간을 비교하는것이 아니기때문에 무조건 else가 됩니다.

$list[$i][wr_comment]를 

$list[$i][wr_last]로 바꾸어보세요 

계속 신경을 써주셔서 감사합니다.
몇 시간 전, 몇 분 전 이렇게 시간을 출력하는 것이
list.skin.php, view.skin.php, view_comment.skin.php, latest 에서는 다 되는데
new.php에서 코멘트(댓글)만 안 되는군요...ㅜㅜ  new.php에서 원글 리스트는 됩니다.
보름 간 이것을 해결하려 했지만, new.php에서는 통일성 있게 그냥 datetime2로 써야 할 것 같습니다.
아뭏든 새해 복 많이 받으시고 즐거운 설연휴 되십시오~^^)

function date_sns($wr_datetime){

global $g4;

$timestamp = strtotime($wr_datetime); // 글쓴날짜시간 Unix timestamp 형식 

$current = $g4['server_time']; // 현재날짜시간 Unix timestamp 형식

// 1년전

if($timestamp > $current - 86400){

if ($timestamp <= $current - 86400) {

$str = "어제";

}

else if ($timestamp <= $current - 3600 * 1) {

$str = (int)(($current - $timestamp) / 3600) . "시간전";

}

else if ($timestamp <= $current - 60 * 1) {

$str = (int)(($current - $timestamp) / 60) . "분전";

}

else {

$str = (int)($current - $timestamp) . "초전";

}

$list['datetime2'] = $str;

}else{

 

    $list['datetime'] = substr($wr_datetime,0,10);

    $list['datetime2'] = $wr_datetime;

    if ($list['datetime'] == $g4['time_ymd'])

        $list['datetime2'] = substr($list['datetime2'],11,5);

    else if (substr($list['datetime'],0,4) == substr($g4['time_ymd'],0,4))

        $list['datetime2'] = substr($list['datetime2'],5,5);

    else if (days_diff($list['datetime']) <= 60)

        $list['datetime2'] = substr($list['datetime2'],5,5);

    else

        $list['datetime2'] = substr($list['datetime2'],0,7);

}

return $list['datetime2'];

}


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

회원로그인

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