0

I am successfully pulling calendars and events from Google. However I am trying like hell to order the results. I'd like to pull events for today only. Any help is super appreciated... Thanks.

$eventsParam = array("orderBy"=>startTime, "timeMin"=>date('d-m-Y') , "timeMax"=>date('d-m-Y')); 
$eventList = $cal->events->listEvents('yoyoyo@gmail.com', $eventsParam);

    foreach($eventList->getItems() as $eventList){

        $eventsData = json_decode($eventList);
        $eventDate = explode('T', $eventList->start->dateTime);

            //Event summary
            print "<br>Summary: ";
            echo $eventList->summary;

            //Event location
            print "<br/> Location: ";
            echo $eventList->location;

            //Event date:
            print "<br/> Date: ";
            echo $eventDate[0];

            //Event time:
            print "<br/> Time: ";
            $eventTime = explode('-', $eventDate[1]);
            echo $eventTime[0];

            echo "<hr>";

    }   
Kara
  • 6,115
  • 16
  • 50
  • 57
barrylachapelle
  • 967
  • 4
  • 13
  • 34

1 Answers1

0

Use array_filter to get the ones that are for today. Then to sort on a on a property of an array of objects, consider using usort and your own comparer. I think your question is similar to this one.

Community
  • 1
  • 1
Bullines
  • 5,626
  • 6
  • 53
  • 93
  • Solution to find todays date `code`$dateMin = date('Y-m-d',mktime(0,0,0,date('m'), date('d'), date('Y'))) . "T00:00:00+00:00"; //this morning $dateMax = date('Y-m-d',mktime(0,0,0,date('m'), date('d')+1, date('Y'))) . "T00:00:00+00:00"; //tomorrow morning $eventsParam = array('timeMin' => date(DATE_ATOM), 'timeMax' => $dateMax); $eventList = $cal->events->listEvents('yoyoyo@gmail.com', $eventsParam);`code` – barrylachapelle Oct 03 '12 at 16:50