테스트 사이트 - 개발 중인 베타 버전입니다

일요일이라면 채택완료

그누x쵸딩 4년 전 조회 1,424

그런데 일요일에는 돌아가지 않게 하고 싶은데

 

이번주 일요일을 뽑는거 찾아보니 

 

if(!$setdate)$setdate = date("Y-m-d");
$today = strtotime($setdate);

echo '<br />이번주 일요일 : '.$sun = date('Y-m-d', (strtotime('SUNDAY', $today) > $today) ? strtotime('LAST SUNDAY', $today) : strtotime('SUNDAY', $today));    // 이번주 일요일

 

이렇게 하니 

  • 이번주 일요일 : 2020-11-08 이렇게 뽑히는군요

 

이제 오늘이 일요일이라면

 

$today_search .= " and SUBSTR(wr_datetime,1,10)=CURDATE() "; //오늘 날짜만 보이기

sql_query("update g5_write_test set ca_name = '완료' where mb_id = 'admin' $today_search ORDER BY RAND() LIMIT 8"); //

 

위코드가 작동안하게 하려면 어떻게 해야 할까요?

고수님 도움을 기다려봅니다.

 

혹시 이렇게 해보면 될까요?

 

if(!$setdate)$setdate = date("Y-m-d");
$today = strtotime($setdate);

$sun = date('Y-m-d', (strtotime('SUNDAY', $today) > $today) ? strtotime('LAST SUNDAY', $today) : strtotime('SUNDAY', $today));  // 이번주 일요일

 

if(!$sun) {

 $today_search .= " and SUBSTR(wr_datetime,1,10)=CURDATE() "; //오늘 날짜만 보이기

 sql_query("update g5_write_test set ca_name = '완료' where mb_id = 'admin' $today_search ORDER BY RAND() LIMIT 8"); //

}

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
e
4년 전

if(!$sun) {

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

if(date('w') != 0) {

오늘이 일요일이 아니라면..

아래 참조..

https://offbyone.tistory.com/38

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

그누x쵸딩
4년 전
감사합니다. 해보겠씁니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인