다음주 월요일 일요일 을 못구하겠어요..ㅠㅠ 채택완료
</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개
$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
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
다음주월요일에 2017-06-12(월)
다음주일요일에 2017-06-11(일)
이렇게 출력됩니다.ㅠㅠ