최신글 질문 드립니다

최신글 질문 드립니다

QA

최신글 질문 드립니다

본문

안뇽하세요


                        <?php
                        $this_date = strtotime(substr($list[$i]['wr_1'],0,4).'-'.substr($list[$i]['wr_1'],4,2).'-'.substr($list[$i]['wr_1'],6,2));
                        $today_date = strtotime(date("Y-m-d"));
                        if ($this_date <= $today_date) {
              $now_dday = 'TODAY';
                        } else {
              $now_dday = 'D-'.ceil(($this_date - $today_date)/86400);
                        }
                        echo $now_dday;
                        ?>

여분필드wr_1에 시작일을 집어넣고 wr_2에 종료일을 집어넣어서

위처럼 디데이 게시물을 불러오고있습니다.

그런데 디데이가 지난 최신글은 안나오도록 없애버리고 싶은데 소스도 줍줍한거라

막막합니다 ㅠ_ㅜ 도움좀 부탁드립니다ㅜ

이 질문에 댓글 쓰기 :

답변 3

전체적인 소스를 확인하지 않아서 잘은 모르겠으나 올려주신 내용만으로 보면 아래처럼 처리하면될꺼 같습니다.


<?php
$this_date = strtotime(substr($list[$i]['wr_1'],0,4).'-'.substr($list[$i]['wr_1'],4,2).'-'.substr($list[$i]['wr_1'],6,2));
$today_date = strtotime(date("Y-m-d"));
if ($this_date <= $today_date) {
    //  $now_dday = 'TODAY';   <-- 이부분만 주석처리하면될꺼 같습니다.
} else {
    $now_dday = 'D-'.ceil(($this_date - $today_date)/86400);
}
echo $now_dday;
?>

 

요렇게 한번 주석처리 해보시고 돌려보시고 피드백은 한번 올려주세요

가장 효율적인 것은

query문을 바꾸는 거죠.

어떤 파일에서 작업하시는 건가요?


<?
$startdate = date("Y-m-d", time()); // 오늘 날짜 가져옴
$enddate = $list[$i]['wr_2']; // 마감일 2017-06-01 <-- 형식으로
$timediffer=strtotime($enddate) - strtotime($startdate);   // 마감일과 오늘의 날짜 차이를 구함
$day = floor(($timediffer)/(60*60*24));

?>

						<?php
						$this_date = strtotime(substr($list[$i]['wr_1'],0,4).'-'.substr($list[$i]['wr_1'],4,2).'-'.substr($list[$i]['wr_1'],6,2));
						$today_date = strtotime(date("Y-m-d"));
						if ($this_date <= $today_date) {

              $now_dday = 'TODAY';
						} else {
              $now_dday = 'D-'.ceil(($this_date - $today_date)/86400);
						}
						echo $now_dday;
						?>




최신글이고 이렇게 사용하고 있습니다.

echo $now_dday;

->

if ($list[$i]['wr_1'] > date('Y-m-d'))

  continue;

echo $now_dday;

 

 



<?
$startdate = date("Y-m-d", time()); // 오늘 날짜 가져옴
$enddate = $list[$i]['wr_2']; // 마감일 2017-06-01 <-- 형식으로
$timediffer=strtotime($enddate) - strtotime($startdate);   // 마감일과 오늘의 날짜 차이를 구함
$day = floor(($timediffer)/(60*60*24));

?>

						<?php
						$this_date = strtotime(substr($list[$i]['wr_1'],0,4).'-'.substr($list[$i]['wr_1'],4,2).'-'.substr($list[$i]['wr_1'],6,2));
						$today_date = strtotime(date("Y-m-d"));
						if ($this_date <= $today_date) {

              $now_dday = 'TODAY';
						} else {
              $now_dday = 'D-'.ceil(($this_date - $today_date)/86400);
						}
						if ($list[$i]['wr_1'] > date('Y-m-d'))
                                                continue;
                                                echo $now_dday;
						?>


마르스컴퍼니님 우선 답변 감사드립니다.말씀해주신대로 했는데 아예 아무것도 출력이 안되어요 ㅠ_ㅜ

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

회원로그인

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