Reputation: 375
Because Google shutted down the other API, I have to re-write my code for v3 API.
I think it is simple but I cannot make it.
I want to get the Start date of every event in my timespan. But how?
I've this code till now:
$start = date(DateTime::ATOM, mktime(0,0,0,date('m'), date('d'), date('Y')));
$end = date(DateTime::ATOM, mktime(23,59,59,12, 31, 2025));
$eventOptions = array("orderBy"=>"startTime",
"singleEvents"=>true,
"timeMin"=>$start,
"timeMax"=>$end);
$events = $service->events->listEvents($calName, $eventOptions);
foreach ($events->getItems() as $event) {
echo $event->getSummary(); //GET TITLE OF EVENT
echo "<br>";
echo $event->getLocation(); //GET LOCATION OF EVENT
// WHAT TO PLACE HERE TO ECHO THE DATE OF THE EVENT?
echo "<br>**------**<br>";
}
I'm getting crazy of this 'simple' thing. Who can help me?
Upvotes: 2
Views: 2661
Reputation: 31
You can output the data by:
echo $event->start->dateTime.' - '.$event->end->dateTime;
For full output of $event object use :
vardump($event);
hope that helps
Upvotes: 3
Reputation: 49
I believe...to get the datetime of the event:
$event->getStart()->dateTime
For just the date:
$event->getStart()->date
You can use the "Resource Representations" found here: https://developers.google.com/google-apps/calendar/v3/reference/events to see all the different event data. Scroll down to:
"start": {
"date": date,
"dateTime": datetime,
"timeZone": string
},
and it should make sense.
Upvotes: 3