복붙노트

PHP : 배열에서 두 날짜 사이의 모든 날짜를 반환합니다.

PHP

PHP : 배열에서 두 날짜 사이의 모든 날짜를 반환합니다.

예상 입력 :

getDatesFromRange( '2010-10-01', '2010-10-05' );

예상 출력 :

Array( '2010-10-01', '2010-10-02', '2010-10-03', '2010-10-04', '2010-10-05' )

해결법

  1. ==============================

    1.

    DatePeriod 클래스를 살펴볼 수도 있습니다.

    $period = new DatePeriod(
         new DateTime('2010-10-01'),
         new DateInterval('P1D'),
         new DateTime('2010-10-05')
    );
    

    DateTime 객체로 배열을 가져와야합니다.

    반복하려면

    foreach ($period as $key => $value) {
        //$value->format('Y-m-d')       
    }
    
  2. ==============================

    2.

    function createDateRangeArray($strDateFrom,$strDateTo)
    {
        // takes two dates formatted as YYYY-MM-DD and creates an
        // inclusive array of the dates between the from and to dates.
    
        // could test validity of dates here but I'm already doing
        // that in the main script
    
        $aryRange=array();
    
        $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),     substr($strDateFrom,8,2),substr($strDateFrom,0,4));
        $iDateTo=mktime(1,0,0,substr($strDateTo,5,2),     substr($strDateTo,8,2),substr($strDateTo,0,4));
    
        if ($iDateTo>=$iDateFrom)
        {
            array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry
            while ($iDateFrom<$iDateTo)
            {
                $iDateFrom+=86400; // add 24 hours
                array_push($aryRange,date('Y-m-d',$iDateFrom));
            }
        }
        return $aryRange;
    }
    

    출처 : http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html

  3. ==============================

    3.

    이것은 매우 유연합니다.

    /**
     * Creating date collection between two dates
     *
     * <code>
     * <?php
     * # Example 1
     * date_range("2014-01-01", "2014-01-20", "+1 day", "m/d/Y");
     *
     * # Example 2. you can use even time
     * date_range("01:00:00", "23:00:00", "+1 hour", "H:i:s");
     * </code>
     *
     * @author Ali OYGUR <alioygur@gmail.com>
     * @param string since any date, time or datetime format
     * @param string until any date, time or datetime format
     * @param string step
     * @param string date of output format
     * @return array
     */
    function date_range($first, $last, $step = '+1 day', $output_format = 'd/m/Y' ) {
    
        $dates = array();
        $current = strtotime($first);
        $last = strtotime($last);
    
        while( $current <= $last ) {
    
            $dates[] = date($output_format, $current);
            $current = strtotime($step, $current);
        }
    
        return $dates;
    }
    
  4. ==============================

    4.

    ViNce가 제공 한 답변에는 해당 기간의 종료 날짜가 포함되지 않습니다.

    PHP 5.3 이상을 사용하는 경우 가장 좋은 방법은 다음과 같은 함수를 사용하는 것입니다.

    /**
     * Generate an array of string dates between 2 dates
     *
     * @param string $start Start date
     * @param string $end End date
     * @param string $format Output format (Default: Y-m-d)
     *
     * @return array
     */
    function getDatesFromRange($start, $end, $format = 'Y-m-d') {
        $array = array();
        $interval = new DateInterval('P1D');
    
        $realEnd = new DateTime($end);
        $realEnd->add($interval);
    
        $period = new DatePeriod(new DateTime($start), $interval, $realEnd);
    
        foreach($period as $date) { 
            $array[] = $date->format($format); 
        }
    
        return $array;
    }
    

    그런 다음 함수를 예상대로 호출합니다.

    getDatesFromRange('2010-10-01', '2010-10-05');
    

    데모 실행

    DatePeriod 클래스에 대한 참고 사항 : DatePeriod의 4 번째 매개 변수를 사용하여 시작 날짜 (DatePeriod :: EXCLUDE_START_DATE)를 제외 할 수 있지만 이번에는 종료 날짜를 포함 할 수 없습니다.

  5. ==============================

    5.

    단순하지만 매력처럼 :

        $period = new DatePeriod(new DateTime('2015-01-01'), new DateInterval('P1D'), new DateTime('2015-01-15 +1 day'));
        foreach ($period as $date) {
            $dates[] = $date->format("Y-m-d");
        }
    
        //ONLY SHOWING
        echo '<pre>';
        var_dump($dates);
        echo '</pre>';
        exit();
    
  6. ==============================

    6.

    이것 좀 봐.

      function GetDays($sStartDate, $sEndDate){  
          // Firstly, format the provided dates.  
          // This function works best with YYYY-MM-DD  
          // but other date formats will work thanks  
          // to strtotime().  
          $sStartDate = gmdate("Y-m-d", strtotime($sStartDate));  
          $sEndDate = gmdate("Y-m-d", strtotime($sEndDate));  
    
          // Start the variable off with the start date  
         $aDays[] = $sStartDate;  
    
         // Set a 'temp' variable, sCurrentDate, with  
         // the start date - before beginning the loop  
         $sCurrentDate = $sStartDate;  
    
         // While the current date is less than the end date  
         while($sCurrentDate < $sEndDate){  
           // Add a day to the current date  
           $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate)));  
    
           // Add this new day to the aDays array  
           $aDays[] = $sCurrentDate;  
         }  
    
         // Once the loop has finished, return the  
         // array of days.  
         return $aDays;  
       }  
    

    ~ 같이 사용하다

    GetDays('2007-01-01', '2007-01-31'); 
    
  7. ==============================

    7.

    이것은 짧고, 달콤하며, PHP4 +에서 작동해야합니다.

    function getDatesFromRange($start, $end){
        $dates = array($start);
        while(end($dates) < $end){
            $dates[] = date('Y-m-d', strtotime(end($dates).' +1 day'));
        }
        return $dates;
    }
    
  8. ==============================

    8.

    이 일을 끝내기위한 여러 가지 방법이 있지만 결국은 PHP 버전에 달려 있습니다. 다음은 모든 솔루션의 요약입니다.

    PHP 버전 가져 오기 :

    echo phpinfo();
    

    PHP 5.3 이상

    $period = new DatePeriod(
         new DateTime('2010-10-01'),
         new DateInterval('P1D'),
         new DateTime('2010-10-05')
    );
    

    PHP 4 이상

    /**
     * creating between two date
     * @param string since
     * @param string until
     * @param string step
     * @param string date format
     * @return array
     * @author Ali OYGUR <alioygur@gmail.com>
     */
    function dateRange($first, $last, $step = '+1 day', $format = 'd/m/Y' ) { 
    
        $dates = array();
        $current = strtotime($first);
        $last = strtotime($last);
    
        while( $current <= $last ) { 
    
            $dates[] = date($format, $current);
            $current = strtotime($step, $current);
        }
    
        return $dates;
    }
    

    PHP <4

    당신은 업그레이 드해야합니다 :)

  9. ==============================

    9.

    다음은 양방향으로 날짜 범위를 반환하는 함수이며 PHP> = 5.2.2에서 작동합니다.

    function createRange($start, $end, $format = 'Y-m-d') {
        $start  = new DateTime($start);
        $end    = new DateTime($end);
        $invert = $start > $end;
    
        $dates = array();
        $dates[] = $start->format($format);
        while ($start != $end) {
            $start->modify(($invert ? '-' : '+') . '1 day');
            $dates[] = $start->format($format);
        }
        return $dates;
    }
    

    예제 사용 :

    print_r(createRange('2010-10-01', '2010-10-05'));
    /*Array
    (
        [0] => 2010-10-01
        [1] => 2010-10-02
        [2] => 2010-10-03
        [3] => 2010-10-04
        [4] => 2010-10-05
    )*/
    
    print_r(createRange('2010-10-05', '2010-10-01', 'j M Y'));
    /*Array
    (
        [0] => 5 Oct 2010
        [1] => 4 Oct 2010
        [2] => 3 Oct 2010
        [3] => 2 Oct 2010
        [4] => 1 Oct 2010
    )*/
    

    데모

  10. ==============================

    10.

    DateTime 객체가있는 PHP 5.2 솔루션 그러나 startDate는 endDate 이전이어야합니다.

    function createRange($startDate, $endDate) {
        $tmpDate = new DateTime($startDate);
        $tmpEndDate = new DateTime($endDate);
    
        $outArray = array();
        do {
            $outArray[] = $tmpDate->format('Y-m-d');
        } while ($tmpDate->modify('+1 day') <= $tmpEndDate);
    
        return $outArray;
    }
    

    사용 :

    $dates = createRange('2010-10-01', '2010-10-05');
    

    $ 날짜는 다음을 포함합니다 :

    Array( '2010-10-01', '2010-10-02', '2010-10-03', '2010-10-04', '2010-10-05' )       
    
  11. ==============================

    11.

    짧은 기능. PHP 5.3 이상. strtotime이 이해할 수있는 날짜 형식의 선택적 세 번째 매개 변수를 사용할 수 있습니다. 끝 <시작 인 경우 방향이 자동으로 바뀝니다.

    function getDatesFromRange($start, $end, $format='Y-m-d') {
        return array_map(function($timestamp) use($format) {
            return date($format, $timestamp);
        },
        range(strtotime($start) + ($start < $end ? 4000 : 8000), strtotime($end) + ($start < $end ? 8000 : 4000), 86400));
    }
    

    테스트:

    date_default_timezone_set('Europe/Berlin');
    print_r(getDatesFromRange( '2016-7-28','2016-8-2' ));
    print_r(getDatesFromRange( '2016-8-2','2016-7-28' ));
    print_r(getDatesFromRange( '2016-10-28','2016-11-2' ));
    print_r(getDatesFromRange( '2016-11-2','2016-10-28' ));
    print_r(getDatesFromRange( '2016-4-2','2016-3-25' ));
    print_r(getDatesFromRange( '2016-3-25','2016-4-2' ));
    print_r(getDatesFromRange( '2016-8-2','2016-7-25' ));
    print_r(getDatesFromRange( '2016-7-25','2016-8-2' ));
    

    산출:

    Array ( [0] => 2016-07-28 [1] => 2016-07-29 [2] => 2016-07-30 [3] => 2016-07-31 [4] => 2016-08-01 [5] => 2016-08-02 ) 
    Array ( [0] => 2016-08-02 [1] => 2016-08-01 [2] => 2016-07-31 [3] => 2016-07-30 [4] => 2016-07-29 [5] => 2016-07-28 ) 
    Array ( [0] => 2016-10-28 [1] => 2016-10-29 [2] => 2016-10-30 [3] => 2016-10-31 [4] => 2016-11-01 [5] => 2016-11-02 ) 
    Array ( [0] => 2016-11-02 [1] => 2016-11-01 [2] => 2016-10-31 [3] => 2016-10-30 [4] => 2016-10-29 [5] => 2016-10-28 ) 
    Array ( [0] => 2016-04-02 [1] => 2016-04-01 [2] => 2016-03-31 [3] => 2016-03-30 [4] => 2016-03-29 [5] => 2016-03-28 [6] => 2016-03-27 [7] => 2016-03-26 [8] => 2016-03-25 ) 
    Array ( [0] => 2016-03-25 [1] => 2016-03-26 [2] => 2016-03-27 [3] => 2016-03-28 [4] => 2016-03-29 [5] => 2016-03-30 [6] => 2016-03-31 [7] => 2016-04-01 [8] => 2016-04-02 ) 
    Array ( [0] => 2016-08-02 [1] => 2016-08-01 [2] => 2016-07-31 [3] => 2016-07-30 [4] => 2016-07-29 [5] => 2016-07-28 [6] => 2016-07-27 [7] => 2016-07-26 [8] => 2016-07-25 ) 
    Array ( [0] => 2016-07-25 [1] => 2016-07-26 [2] => 2016-07-27 [3] => 2016-07-28 [4] => 2016-07-29 [5] => 2016-07-30 [6] => 2016-07-31 [7] => 2016-08-01 [8] => 2016-08-02 )
    
  12. ==============================

    12.

    function createDateRangeArray($start, $end) {
    // Modified by JJ Geewax
    
    $range = array();
    
    if (is_string($start) === true) $start = strtotime($start);
    if (is_string($end) === true ) $end = strtotime($end);
    
    if ($start > $end) return createDateRangeArray($end, $start);
    
    do {
    $range[] = date('Y-m-d', $start);
    $start = strtotime("+ 1 day", $start);
    }
    while($start < $end);
    
    return $range;
    } 
    

    출처 : http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html

  13. ==============================

    13.

    <?
    print_r(getDatesFromRange( '2010-10-01', '2010-10-05' ));
    
    function getDatesFromRange($startDate, $endDate)
    {
        $return = array($startDate);
        $start = $startDate;
        $i=1;
        if (strtotime($startDate) < strtotime($endDate))
        {
           while (strtotime($start) < strtotime($endDate))
            {
                $start = date('Y-m-d', strtotime($startDate.'+'.$i.' days'));
                $return[] = $start;
                $i++;
            }
        }
    
        return $return;
    }
    
  14. ==============================

    14.

    Carbon https://github.com/briannesbitt/Carbon을 사용하여이를 수행하는 방법은 다음과 같습니다.

    public function buildDateRangeArray($first, $last)
    {
        while ($first <= $last) {
            $dates[] = $first->toDateString();
    
            $first->addDay();
        }
    
        return $dates;
    }
    

    이것은 물론 Carbon을 사용하지 않도록 조정할 수 있습니다. 함수에 전달 된 $ first 및 $ last 매개 변수는 Carbon 인스턴스입니다.

  15. ==============================

    15.

    // will return dates array
    function returnBetweenDates( $startDate, $endDate ){
        $startStamp = strtotime(  $startDate );
        $endStamp   = strtotime(  $endDate );
    
        if( $endStamp > $startStamp ){
            while( $endStamp >= $startStamp ){
    
                $dateArr[] = date( 'Y-m-d', $startStamp );
    
                $startStamp = strtotime( ' +1 day ', $startStamp );
    
            }
            return $dateArr;    
        }else{
            return $startDate;
        }
    
    }
    
    returnBetweenDates( '2014-09-16', '2014-09-26' );
    
    // print_r( returnBetweenDates( '2014-09-16', '2014-09-26' ) );
    

    아래와 같이 배열을 반환합니다 :

    Array
    (
        [0] => 2014-09-16
        [1] => 2014-09-17
        [2] => 2014-09-18
        [3] => 2014-09-19
        [4] => 2014-09-20
        [5] => 2014-09-21
        [6] => 2014-09-22
        [7] => 2014-09-23
        [8] => 2014-09-24
        [9] => 2014-09-25
        [10] => 2014-09-26
    )
    
  16. ==============================

    16.

    $report_starting_date=date('2014-09-16');
    $report_ending_date=date('2014-09-26');
    $report_starting_date1=date('Y-m-d',strtotime($report_starting_date.'-1 day'));
    while (strtotime($report_starting_date1)<strtotime($report_ending_date))
    {
    
        $report_starting_date1=date('Y-m-d',strtotime($report_starting_date1.'+1 day'));
        $dates[]=$report_starting_date1;
      } 
      print_r($dates);
    
     // dates    ('2014-09-16', '2014-09-26')
    
    
     //print result    Array
    (
    [0] => 2014-09-16
    [1] => 2014-09-17
    [2] => 2014-09-18
    [3] => 2014-09-19
    [4] => 2014-09-20
    [5] => 2014-09-21
    [6] => 2014-09-22
    [7] => 2014-09-23
    [8] => 2014-09-24
    [9] => 2014-09-25
    [10] => 2014-09-26
    )
    
  17. ==============================

    17.

    // Specify the start date. This date can be any English textual format  
    $date_from = "2018-02-03";   
    $date_from = strtotime($date_from); // Convert date to a UNIX timestamp  
    
    // Specify the end date. This date can be any English textual format  
    $date_to = "2018-09-10";  
    $date_to = strtotime($date_to); // Convert date to a UNIX timestamp  
    
    // Loop from the start date to end date and output all dates inbetween  
    for ($i=$date_from; $i<=$date_to; $i+=86400) {  
        echo date("Y-m-d", $i).'<br />';  
    } 
    
  18. ==============================

    18.

    나는 이것이 가장 짧은 대답이라고 생각한다.

    원하는대로 코드 편집

    for ($x=strtotime('2015-12-01');$x<=strtotime('2015-12-30');$x+=86400)
    echo date('Y-m-d',$x);
    
  19. ==============================

    19.

    여기에 또 다른 해결책이 있습니다. 이것을 확인하십시오.

    $first = '10/30/2017'; //starting date
    $last= '10/11/2017';   //ending date
    $first_time_arr=explode('/',$first); 
    $last_time_arr=explode('/',$last);
    //create timestamp of starting date
    $start_timestamp=mktime(0,0,0, $first_time_arr[0], $first_time_arr[1],$first_time_arr[2]);
    //create timestamp of ending date
    $end_timestamp=mktime(0,0,0, $last_time_arr[0], $last_time_arr[1],$last_time_arr[2]);
    $date_arr=array();
    for($i=$start_timestamp;$i<=$end_timestamp;$i=$i+86400){
        $date_arr[]=date("Y-m-d",$i); //this will save all dates in array
    }
    
  20. ==============================

    20.

    public static function countDays($date1,$date2)
    {
        $date1 = strtotime($date1); // or your date as well
        $date2 = strtotime($date2);
        $datediff = $date1 - $date2;
        return floor($datediff/(60*60*24));
    }
    
    public static function dateRange($date1,$date2)
    {
        $count = static::countDays($date1,$date2) + 1;
        $dates = array();
        for($i=0;$i<$count;$i++)
        {
            $dates[] = date("Y-m-d",strtotime($date2.'+'.$i.' days'));
        }
        return $dates;
    }
    
  21. ==============================

    21.

    function datesbetween ($date1,$date2)
    {
        $dates= array();
        for ($i = $date1
           ; $i<= $date1
           ; $i=date_add($i, date_interval_create_from_date_string('1 days')) ) 
        {            
           $dates[] = clone $i;
        }
        return $dates;
    }
    
  22. ==============================

    22.

    내 PHP 발견 그 array_push () 배열의 요소의 새 번호를 반환합니다.

    끝 날짜 일치를 확인하고 $ x를 증가 시키며 빈 while 루프의 두 부분으로 구성된 조건문 내에서 새 요소를 모두 밀어 낼 수있었습니다.

    function getDatesFromRange($a,$b,$x=0,$dates=[]){
        while(end($dates)!=$b && $x=array_push($dates,date("Y-m-d",strtotime("$a +$x day"))));
        return $dates;
    }
    var_export(getDatesFromRange('2010-10-01','2010-10-05'));
    

    이 페이지에서 가장 유사한 기능은 drolex (나는 당신이 나를 믿는다면, 나는 내가 광산을 썼을 때까지 실제로 발견하지 못했다.)이다. 크고 작은 날짜 범위에 걸쳐 몇 가지 속도 테스트를 수행했으며 서로 자주 이길 수있는 것처럼 보였으므로이를 평등 한 수행자라고합니다. 다음은 몇 가지 다른 비교입니다.

    ** 몇 가지 중요한 메모 :

    1 - 날짜 문자열은 함수에 공급되기 전에 유효성을 검사해야합니다.

    2- 위의 기능은 앞으로 움직이는 날짜 범위 만 처리 할 수 ​​있습니다. 역순으로 날짜 범위를 이동하려면 함수 호출에서 날짜 순서를 반대로하고 $ x = 뒤에 빼기를 추가하면됩니다. (꽤 매끄러운, 어?)

    function getDatesFromRange($a,$b,$x=0,$dates=[]){
        while(end($dates)!=$b && $x=-array_push($dates,date("Y-m-d",strtotime("$a +$x day"))));
        return $dates;
    }
    var_export(getDatesFromRange('2010-10-05','2010-10-01'));
    

    한 번 더 확장 / 고려 ...

    다국적 (또는 지저분한) 사용자 기반이 있고 함수가 다른 유효한 형식으로 시작 및 끝 날짜를 수신 할 수 있어야하며 유효한 형식으로 배열을 출력 할 수 있어야한다고 가정 해보십시오. 사소한 수정으로, 나는 그것을위한 해결책을 제공했다.

    "유효하다"는 말은 YYYY-MM-DD, MM / DD / YYY 및 DD-MM-YYYY를 의미하며, 다른 형식이 필요한 경우 strtotime의 이해력에 이르게됩니다.

    여기에 데모가 있습니다.

    암호:

    function getDatesFromRange($a,$b,$format='Y-m-d',$dates=[],$x=0){
        while(date($format,strtotime(end($dates)))!=date($format,strtotime($b)) && $x=array_push($dates,date($format,strtotime("$a +$x day"))));
        return $dates;
    }
    
    $formats=array("Computer"=>'Y-m-d',"American"=>'m/d/Y','Non-American'=>'d-m-Y');
    $start='15-02-2017';    // Non-American formatted start date
    $end='2017-02-27';  // Computer formatted start date
    foreach($formats as $label=>$format){
        echo "<br>$label<br>";
        var_export(getDatesFromRange($start,$end,$format));
        echo "<br>";
    }
    

    산출

    Computer
    array ( 0 => '2017-02-15', 1 => '2017-02-16', 2 => '2017-02-17', 3 => '2017-02-18',
            4 => '2017-02-19', 5 => '2017-02-20', 6 => '2017-02-21', 7 => '2017-02-22',
            8 => '2017-02-23', 9 => '2017-02-24', 10 => '2017-02-25', 11 => '2017-02-26',
            12 => '2017-02-27', )
    
    American
    array ( 0 => '02/15/2017', 1 => '02/16/2017', 2 => '02/17/2017', 3 => '02/18/2017',
            4 => '02/19/2017', 5 => '02/20/2017', 6 => '02/21/2017', 7 => '02/22/2017',
            8 => '02/23/2017', 9 => '02/24/2017', 10 => '02/25/2017', 11 => '02/26/2017',
            12 => '02/27/2017', )
    
    Non-American
    array ( 0 => '15-02-2017', 1 => '16-02-2017', 2 => '17-02-2017', 3 => '18-02-2017',
            4 => '19-02-2017', 5 => '20-02-2017', 6 => '21-02-2017', 7 => '22-02-2017',
            8 => '23-02-2017', 9 => '24-02-2017', 10 => '25-02-2017', 11 => '26-02-2017',
            12 => '27-02-2017', )
    

    이제 어떤 사람들은 버그 투성이 인 행동 때문에 strtotime ()을 100 % 신뢰하지 않습니다. 나는 그것이 윤일에서 한 달을 뛰어 오르려고 할 때 파울을 일으킬 것이라고 읽은 것 같습니다. 그러나, 누군가가 그것을 틀리게 증명하기 위해 그것을 재현 할 수 없다면, strtotime ()은 당신이 하루 만 증가 할 때 당신을 실망시키지 않을 것입니다.

  23. ==============================

    23.

    Mostafa의 대답을 완성하기 위해, 이것은 확실히 간단하고 효율적인 방법입니다.

    function getDatesFromRange($start_date, $end_date, $date_format = 'Y-m-d')
       {
          $dates_array = array();
          for ($x = strtotime($start_date); $x <= strtotime($end_date); $x += 86400) {
             array_push($dates_array, date($date_format, $x));
          }
    
          return $dates_array;
       }
    
       // see the dates in the array
       print_r( getDatesFromRange('2017-02-09', '2017-02-19') );
    

    함수를 호출 할 때 세 번째 매개 변수를 추가하면 기본 출력 날짜 형식을 변경할 수도 있습니다. 그렇지 않으면 'Y-m-d'로 설정된 기본 형식이 사용됩니다.

    나는 그것이 도움이되기를 바랍니다 :)

  24. ==============================

    24.

    function getWeekdayDatesFrom($format, $start_date_epoch, $end_date_epoch, $range) {
    
        $dates_arr = array();
    
        if( ! $range) {
            $range = round(abs($start_date_epoch-$end_date_epoch)/86400) + 1;
        } else {
            $range = $range + 1; //end date inclusive
        }
    
        $current_date_epoch = $start_date_epoch;
    
        for($i = 1; $i <= $range; $i+1) {
    
            $d = date('N',  $current_date_epoch);
    
            if($d <= 5) { // not sat or sun
                $dates_arr[] = "'".date($format, $current_date_epoch)."'";
            }
    
            $next_day_epoch = strtotime('+'.$i.'day', $start_date_epoch);
            $i++;
            $current_date_epoch = $next_day_epoch;
    
        }
    
        return $dates_arr;
    } 
    
  25. ==============================

    25.

    $arr = range(strtotime("2013-12-01"),strtotime("2013-12-31"), "86400");
    array_walk_recursive($arr, function(&$element) { $element = date("Y-m-d", $element); });
    print_r ($arr);
    
  26. from https://stackoverflow.com/questions/4312439/php-return-all-dates-between-two-dates-in-an-array by cc-by-sa and MIT lisence