특정기간동안 날짜구하기 strtotime() date()


특정기간동안 날짜구하기 strtotime() date()

업무노트 특정기간동안 날짜구하기 strtotime() date() 당근먹는개냥이 2016. 8. 29. 12:52 이웃추가 본문 기타 기능 특정일로부터 특정기간동안 날짜를 구해서 배열로 만들자 여러가지 방법들이 있겠지만 나는 아래와 같이 생각해 보았다는 것을~ 워어 // 오늘날짜 $nDate = date('Ymd'); // 배열 담을 곳 $strWeek = array(); // 오늘포함 이전 1주일(7일)간 날짜를 구하자 for ($i = 0; $i < 7; $i++) { $strWeek[] = date('Ymd', strtotime("-{$i} day", strtotime($nDate))); } (1) $nDate를 strtotime()으로 형변환 해주는 것에 주의 (2) strtotime의 파라미터로 "-{$i} day"와 같은 유동변수를 사용하여 변수값을 인자로 사용...


#PHP #strtotime #날짜계산 #유동변수

원문링크 : 특정기간동안 날짜구하기 strtotime() date()