일요일이라면

일요일이라면

QA

일요일이라면

본문

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

 

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

 

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

if(!$sun) {

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

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

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

아래 참조..

https://offbyone.tistory.com/38

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

회원로그인

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