글쓴 년월일과 현재의 timestamp값을 비교한다?? 정보
글쓴 년월일과 현재의 timestamp값을 비교한다??본문
<? //코멘트 쓰기 출력시작
$now_timestamp=time(); //현재시간을 timestamp로 받는다.
$comment_sql = "select wr_datetime from $write_table where wr_id = '$wr_id' and wr_is_comment = '0'";
$comment_datetime = sql_fetch($comment_sql);
$comment[year] = substr($comment_datetime[wr_datetime],0,4); //글쓴 년도를 받는다
$comment[mon] = substr($comment_datetime[wr_datetime],5,2); //글쓴 월을 받는다
$comment[day] = substr($comment_datetime[wr_datetime],8,2); //글쓴 날짜를 받는다
$comment[timestamp] = mktime(23, 59, 59, $comment[mon], $comment[day]+2, $comment[year]); // 글쓴년월일+7을 timestamp로 받는다.
if($comment[timestamp] > $now_timestamp){ //글쓴년월일과 현재의 timestamp값을 비교한다.
?>
<? if($coment[timestamp] > $now_timestamp){ //글쓴년월일과 현재의 timestamp값을 비교한다.?>
이 부분인데
2번째줄에 변수선언에서 time(); 이게 맞나요?? 코멘트가 나오질 않네요 저거 삭제하니 잘나와서;
$now_timestamp=time(); //현재시간을 timestamp로 받는다.
$comment_sql = "select wr_datetime from $write_table where wr_id = '$wr_id' and wr_is_comment = '0'";
$comment_datetime = sql_fetch($comment_sql);
$comment[year] = substr($comment_datetime[wr_datetime],0,4); //글쓴 년도를 받는다
$comment[mon] = substr($comment_datetime[wr_datetime],5,2); //글쓴 월을 받는다
$comment[day] = substr($comment_datetime[wr_datetime],8,2); //글쓴 날짜를 받는다
$comment[timestamp] = mktime(23, 59, 59, $comment[mon], $comment[day]+2, $comment[year]); // 글쓴년월일+7을 timestamp로 받는다.
if($comment[timestamp] > $now_timestamp){ //글쓴년월일과 현재의 timestamp값을 비교한다.
?>
<? if($coment[timestamp] > $now_timestamp){ //글쓴년월일과 현재의 timestamp값을 비교한다.?>
이 부분인데
2번째줄에 변수선언에서 time(); 이게 맞나요?? 코멘트가 나오질 않네요 저거 삭제하니 잘나와서;
댓글 전체
용도가 뭔지 모르겠지만 3번째 줄 쿼리문도 이상하네요
wr_id 값을 지정해서 쿼리하는데 wr_is_comment=0 인 것을 찾는 이유가 뭔가요?
예를들어 wr_id = 3 인 게시물이 원글이라면 wr_is_comment=0 일 것이고
코멘트라면 wr_is_comment는 0 이 될 수가 없습니다
그리고 현재 시각은 궅이 time()함수를 쓸 필요 없이
$now_time= $g4[time_ymdhis]; 이렇게 사용 하면 됩니다
아래쪽의 2일 후 계산하는 것도 간단하게 한줄로
$comment_time = date("Y-m-d 23:59:59", strtotime("$comment_datetime[wr_datetime] +2 day"));
마지막 이 조건은 말이 안되는 조건문 입니다
if($coment[timestamp] > $now_timestamp)
등록 시각은 과거인데 현재 시각보다 클 수가 없죠
wr_id 값을 지정해서 쿼리하는데 wr_is_comment=0 인 것을 찾는 이유가 뭔가요?
예를들어 wr_id = 3 인 게시물이 원글이라면 wr_is_comment=0 일 것이고
코멘트라면 wr_is_comment는 0 이 될 수가 없습니다
그리고 현재 시각은 궅이 time()함수를 쓸 필요 없이
$now_time= $g4[time_ymdhis]; 이렇게 사용 하면 됩니다
아래쪽의 2일 후 계산하는 것도 간단하게 한줄로
$comment_time = date("Y-m-d 23:59:59", strtotime("$comment_datetime[wr_datetime] +2 day"));
마지막 이 조건은 말이 안되는 조건문 입니다
if($coment[timestamp] > $now_timestamp)
등록 시각은 과거인데 현재 시각보다 클 수가 없죠
균이님도 감사드립니다!
time(); 이렇게하면 리눅스 시간이 나오는데요
date() 처리 해줘야 정상 처리가 됩니다.
그래서 time()함수 저는 잘 안쓰죠 가끔 꼭 필요한 곳 빼놓구는...
date() 처리 해줘야 정상 처리가 됩니다.
그래서 time()함수 저는 잘 안쓰죠 가끔 꼭 필요한 곳 빼놓구는...
네이트온으로 직접 해주셔서 감사합니다^^