按时间选择Google日历活动

As I'm working on a digital signage using Google Calendar API - in PHP, I would like to list all events of a day, but not the events back in time (earlier hours than now). It turns out that Google API will only serve the whole day - from today's date and foreward in time using the timeMin, but will not discard events from earlier then "now()" time. Has anybody seen the same - or have any other solution to this apart from bringing in the whole array a second time and do another filtering? I would rather like to have this dine in my PHP server-side as the ajax-xlient I'm using would only need to pick up raw data without any further sorting.

$service = new Google_Service_Calendar($client);
$batch = new Google_Http_Batch($client);

$optParams = array(
  'maxResults' => 10,
  'orderBy' => 'startTime',
  'singleEvents' => TRUE,
  'timeMin' => Date('c')
);

Check the event:list

timeMax

Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time. Must be an RFC3339 timestamp with mandatory time zone offset, e.g., 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but will be ignored.

timeMin

Lower bound (inclusive) for an event's end time to filter by. Optional. The default is not to filter by end time. Must be an RFC3339 timestamp with mandatory time zone offset, e.g., 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but will be ignored.

Here is a sample calendar :

enter image description here

Query both event with the parameter :

timeMax:2017-02-07T23:00:00+0000
timeMin:2017-02-07T11:00:00+0000

Query to get one event (Sample) :

timeMax:2017-02-07T23:00:00+0000
timeMin:2017-02-07T11:00:00+0000

Note:

Specify your timezone when requesting for the event list.

For your reference: