일요일이라면

일요일이라면

QA

일요일이라면

답변 1

본문

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

 

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

 

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

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
filter #php ×
전체 15,331
© SIRSOFT
현재 페이지 제일 처음으로