최신글 질문 드립니다
안뇽하세요
Copy
<?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개 / 댓글 6개
마르스컴퍼니
2022-11-11 (금) 16:55:27
echo $now_dday;
->
if ($list[$i]['wr_1'] > date('Y-m-d'))
continue;
echo $now_dday;
답변에 대한 댓글 1개
2022-11-11 (금) 17:56:59
2022-11-11 (금) 13:28:34
가장 효율적인 것은
query문을 바꾸는 거죠.
어떤 파일에서 작업하시는 건가요?
답변에 대한 댓글 3개
2022-11-11 (금) 15:56:38
[code]
<?
$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;
?>
[/code]
최신글이고 이렇게 사용하고 있습니다.
<?
$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;
?>
[/code]
최신글이고 이렇게 사용하고 있습니다.
2022-11-11 (금) 10:33:35
전체적인 소스를 확인하지 않아서 잘은 모르겠으나 올려주신 내용만으로 보면 아래처럼 처리하면될꺼 같습니다.
Copy
<?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;
?>
요렇게 한번 주석처리 해보시고 돌려보시고 피드백은 한번 올려주세요
답변에 대한 댓글 2개
2022-11-11 (금) 15:53:16
이걸 주석처리하면 아예 투데이가 삭제되는거고요....제가 말씀드린건 시작일~종료일(투데이)이 끝나면 게시물 자체가 안나도오록 하고싶은것입니다.
답변을 작성하려면 로그인이 필요합니다.
<?
$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;
?>
[/code]
마르스컴퍼니님 우선 답변 감사드립니다.말씀해주신대로 했는데 아예 아무것도 출력이 안되어요 ㅠ_ㅜ