title: PHP: search missing dates from date-string
body: <p>I have s string separated by comma containing a list of dates. This list has been made with mySQL "Group_concat" command and looks like this:</p>
  
  <pre><code>11.01.2017, 18.01.2017, 25.01.2017, 01.02.2017, 08.02.2017, 01.03.2017, 08.03.2017
  </code></pre>
  
  <p>The dates have all the same weekdays, e.g. Mondays. Some Mondays are missing in the list, in my example February 15th and 20th 2017.</p>
  
  <p>I'm looking for the missing Mondays of the list and have so far this code:</p>
  
  <pre><code>$weekday = 1
  //$Kurstage = explode(", ",$rowK-&gt;listagg_2 );
  $Kurstage = explode(", ","11.01.2017, 18.01.2017, 25.01.2017, 01.02.2017, 08.02.2017, 01.03.2017, 08.03.2017" );
  $dateStart = date_create( "11.01.2017");
  $dateEnd   = date_create( "08.03.2017");
  $missing_dates = array();
  $interval  = new DateInterval('P1D');
  $period    = new DatePeriod($dateStart, $interval, $dateEnd);
  echo "dateStart:". $dateStart-&gt;format( "Y-m-d" ) . ", dateEnd:  " .$dateEnd-&gt;format( "Y-m-d" )."&lt;br /&gt;";
  foreach($period as $day)
  {
      if ( $day-&gt;format( "w" ) == $weekday )
      {               
          if (! in_array( $day, $Kurstage))
          {
              echo $rowK-&gt;code. " - ". $day-&gt;format( "Y-m-d" ) ."&lt;br /&gt;";
          }
      }
  }
  </code></pre>
  
  <p>I assume the problem is, that the date in the array created with explode is not recognized as a date.</p>