title: Filtering Event List Google Calendar PHP
body: <p>I am trying to fetch events that lie between certain user-given dates from a google calendar using the following code segment:</p>
  
  <pre><code>form name="dates" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
    Start: &lt;input type="date" name="start"&gt;
    End: &lt;input type="date" name="end"&gt;
    &lt;br /&gt;
    &lt;input type="submit" name="submit" value="Anzeigen"&gt;
  &lt;/form&gt;
  
  &lt;?php
  if(isset($_POST['submit'])) 
  { 
      echo "Dates were chosen: Start " . date($_POST['start']) . ' and End ' . date($_POST['end']);
      // Get the API client and construct the service object.
      $client = getClient();
      $service = new Google_Service_Calendar($client);
  
      // Print the next 10 events on the user's calendar.
      $calendarId = 'bkrni7gfaiumlahibu0mnifjvk@group.calendar.google.com';
      $optParams = array(
        'maxResults' =&gt; 10,
        'orderBy' =&gt; 'startTime',
        'singleEvents' =&gt; TRUE,
        'timeMin' =&gt; date($_POST['start']),
      );
      $results = $service-&gt;events-&gt;listEvents($calendarId, $optParams);
  
      if (count($results-&gt;getItems()) == 0) {
        print "No upcoming events found.\n";
      } else {
        print "Upcoming events:\n";
        foreach ($results-&gt;getItems() as $event) {
          $start = $event-&gt;start-&gt;dateTime;
          if (empty($start)) {
            $start = $event-&gt;start-&gt;date;
          }
          printf("%s (%s)\n", $event-&gt;getSummary(), $start);
        }
      }
  } else {
      echo 'Bitte ein Start- und Enddatum auswählen.';
  }
  ?&gt;
  </code></pre>
  
  <p>The date picking works just fine, the chosen dates are shown, yet I get the following php error:</p>
  
  <pre><code>[29-May-2015 17:34:05 Europe/Berlin] PHP Fatal error:  Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/calendar/v3/calendars/bkrni7gfaiumlahibu0mnifjvk%40group.calendar.google.com/events?maxResults=10&amp;orderBy=startTime&amp;singleEvents=true&amp;timeMin=2015-05-31CEST00%3A00: (400) Bad Request' in /html/calendar/api/google-api-php-client/src/Google/Http/REST.php:110
  Stack trace:
  #0 /html/calendar/api/google-api-php-client/src/Google/Http/REST.php(62): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request), Object(Google_Client))
  #1 [internal function]: Google_Http_REST::doExecute(Object(Google_Client), Object(Google_Http_Request))
  #2 /html/calendar/api/google-api-php-client/src/Google/Task/Runner.php(174): call_user_func_array(Array, Array)
  #3 /html/calendar/api/google-api-php-client/src/Google/Http/REST.php(46): Google_Task_Runner-&gt;run()
  #4 /html/calendar/api/google-api-php-client/src/Google/Client.php(590): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
  #5 /html/calendar/ap in /html/calendar/api/google-api-php-client/src/Google/Http/REST.php on line 110
  </code></pre>
  
  <p>Why does it fail, since according to <a href="https://developers.google.com/google-apps/calendar/v3/reference/events/list#parameters" rel="nofollow">this API</a> the timeMin should be a dateTime.</p>