The date range is set. Nr: 2013-11-04 and 2013-11-20. How to display all dates between them in a string, checking for the existence of these dates?

  • What is existence? Where? - xEdelweiss pm

1 answer 1

To get all the dates in a range, use DatePeriod :

$from = new DateTime('2013-04-11'); $to = new DateTime('2013-04-20'); $period = new DatePeriod($from, new DateInterval('P1D'), $to); $arrayOfDates = array_map( function($item){return $item->format('Ymd');}, iterator_to_array($period) ); 
  • Thank! Everything is working. - NoName
  • And here's another. Suppose there are two other dates. For example, 2013-04-10 and 2013-05-10 How do you know if each of the dates we received between the first period relate to the period of the second dates? - NoName
  • one
    all figured out. - NoName
  • > all figured out. It's great :) - xEdelweiss