$date_1 = "2008-05-29"; //시작일
$date_2 = "2008-06-10"; //종료일
$d1_data = explode("-",$date_1);
$d2_data = explode("-",$date_2);
$data1_str = " " . "$d1_data[1]" . "/" . "$d1_data[2]" . "/" . "$d1_data[0]";
$data2_str = " " . "$d2_data[1]" . "/" . "$d2_data[2]" . "/" . "$d2_data[0]";
$d1_strtotime = strtotime($data1_str);
$d2_strtotime = strtotime($data2_str);
while($d1_strtotime != $d2_strtotime){
$d1_strtotime = strtotime("+1 day",$d1_strtotime);
print $sing=date("Y-m-d",$d1_strtotime) . "<br>";
}
//RESULT
2008-05-30
2008-05-31
2008-06-01
2008-06-02
2008-06-03
2008-06-04
2008-06-05
2008-06-06
2008-06-07
2008-06-08
2008-06-09
2008-06-10
===============================================================================
$date_1 = "2008-05-29";
$date_2 = "2008-06-02";
$d1_data = explode("-",$date_1);
$d2_data = explode("-",$date_2);
$data1_str = " " . "$d1_data[1]" . "/" . "$d1_data[2]" . "/" . "$d1_data[0]";
$data2_str = " " . "$d2_data[1]" . "/" . "$d2_data[2]" . "/" . "$d2_data[0]";
$d1_strtotime = strtotime($data1_str);
$d2_strtotime = strtotime($data2_str);
$d1_strtotime = strtotime("-1 day",$d1_strtotime);
while($d1_strtotime != $d2_strtotime){
$d1_strtotime = strtotime("+1 day",$d1_strtotime);
echo $sing=date("Y-m-d",$d1_strtotime) . "<br>";
}
//RESULT
2008-05-29
2008-05-30
2008-05-31
2008-06-01
2008-06-02
'JOB > PHP' 카테고리의 다른 글
PHP의 URL 변수 관리 [출처] [TIP] PHP의 URL 변수 관리 (네이버 OpenAPI 공식 카페) |작성자 openapi (0) | 2010.07.22 |
---|---|
eAccelerator 설치 (0) | 2010.04.16 |