다음주 월요일 일요일 을 못구하겠어요..ㅠㅠ

다음주 월요일 일요일 을 못구하겠어요..ㅠㅠ

QA

다음주 월요일 일요일 을 못구하겠어요..ㅠㅠ

본문


$this_week_chk = date('w')-1; // 오늘
$this_week_start = date("Y-m-d",strtotime("-".$this_week_chk." days")); // 이번주 월
$this_week_end = date("Y-m-d",strtotime("+".$this_week_chk." days")); // 이번주 일
 
$next_week_chk = ??????????
$next_week_start = date("Y-m-d",strtotime("-".$next_week_chk." days")); // 다음주 월
$next_week_end = date("Y-m-d",strtotime("+".$next_week_chk." days")); // 다음주 일

이번주월요일, 이번주일요일은 구햇는데

다음주 월요일과 일요일은 어떻게 구할수있나요?ㅠㅠ

이 질문에 댓글 쓰기 :

답변 3

$this_week_chk = date('w'); //요일을 숫자로 표시 일:0, 월:1, 화:2, 수:3, 목:4, 금:5, 토:6

$this_week_start = date("Y-m-d",strtotime("-".($this_week_chk - 1)." days")); // 이번주 월

$this_week_end = date("Y-m-d",strtotime("+".(7 -$this_week_chk)." days")); // 이번주 일

 

$next_week_start = date('Y-m-d',strtotime($this_week_start.' +7 day')); // 다음주 월

$next_week_end = date('Y-m-d',strtotime($next_week_start.' +6 day')); // 다음주 일

echo "다음주월:".$next_week_start."<br>";

echo "다음주일:".$next_week_end."<br>";


$next_week_start = date("Y-m-d",strtotime("next week monday")); // 다음주 월
$next_week_end = date("Y-m-d",strtotime("next week sunday")); // 다음주 일

 

이렇게 해보시면 어떨까요?

그럼 이렇게 하면 어떨지요?

 


$gendate = new DateTime();
$next_week_start = $gendate->setISODate(date("Y"),date("W")+1,1)->format('Y-m-d');
$next_week_end = $gendate->setISODate(date("Y"),date("W")+2,0)->format('Y-m-d');

 

출처: https://stackoverflow.com/questions/20780834/how-to-get-date-from-week-number-day-number-and-year

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

회원로그인

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