-3

I have check-in column and check-out column in my mysql table. I am posting this dates with UI-Datepicker.

eg: I am trying to block the dates in the datepicker. I have dates like this in database

check in = 2015-06-15

check out = 2015-06-20

Now i want to get dates like this

2015-06-15, 2015-06-16, 2015-06-17, 2015-06-18, 2015-06-19, 2015-06-20

How to get dates like above I mentioned. So please help me and resolve my problem.

Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55
Saravana
  • 258
  • 7
  • 17
  • 2
    http://stackoverflow.com/questions/4312439/php-return-all-dates-between-two-dates-in-an-array – Umair Khan May 28 '15 at 06:17
  • this type of question is already been ask... follow this liknk `http://stackoverflow.com/questions/30497867/how-does-php-output-every-day-between-start-day-and-end-day` – karvin.developer May 28 '15 at 06:18
  • pure mysql solution http://stackoverflow.com/questions/2157282/generate-days-from-date-range – jkavalik May 28 '15 at 06:20

1 Answers1

3
<?php
$date_from = strtotime("10 September 2000");
$date_to = strtotime("15 September 2000");

function list_days($date_from,$date_to){
    $arr_days = array();
    $day_passed = ($date_to - $date_from); //seconds
    $day_passed = ($day_passed/86400); //days

    $counter = 1;
    $day_to_display = $date_from;
    while($counter < $day_passed){
        $day_to_display += 86400;
        //echo date("F j, Y \n", $day_to_display);
        $arr_days[] = date('o-m-d',$day_to_display);
        $counter++;
    }

    return $arr_days;
}

print_r(list_days($date_from,$date_to));
?>
ram obrero
  • 197
  • 10