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

다음주 월요일 일요일 을 못구하겠어요..ㅠㅠ 채택완료

훈훈훈훈훈 8년 전 조회 9,353

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

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

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

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

답변 3개

채택된 답변
+20 포인트
그누위즈

$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." ";

echo "다음주일:".$next_week_end." ";

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

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

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

 

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

 

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

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

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

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

 

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

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

답변에 대한 댓글 1개

훈훈훈훈훈
8년 전
말씀해주신대로하니
다음주월요일에 2017-06-12(월)
다음주일요일에 2017-06-11(일)
이렇게 출력됩니다.ㅠㅠ

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

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

로그인