Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Google_Service_Calendar Event Date Time

$startDateTime = new Google_Service_Calendar_EventDateTime();
$endDateTime = new Google_Service_Calendar_EventDateTime();

$startDateTime->dateTime = date('c', strtotime(date('2022-02-04 10:30')));
$endDateTime->dateTime = date('c', strtotime(date('2022-02-04 11:30')));

$startDateTime->timeZone = 'America/Montreal';
$endDateTime->timeZone = 'America/Montreal';

// auth process
$googleClient = new Google_Client();
$googleClient->setApplicationName("Google Calendar");
$googleClient->setAuthConfig(CREDENTIALS_PATH);
$googleClient->setScopes([SCOPES]);
$googleClient->setSubject(CALENDAR_ID);
$calendarService = new Google_Service_Calendar($googleClient);

// retrieve event
$eventId = 89;  // some example event id
$createdEvent = $calendarService->events->get(CALENDAR_ID, $eventId);

$createdEvent->setStart($startDateTime);
$createdEvent->setEnd($endDateTime);

$updatedEvent = $calendarService->events->update(
  CALENDAR_ID, 
  $createdEvent->getId(), 
  $createdEvent
);
 
PREVIOUS NEXT
Tagged: #Event #Date #Time
ADD COMMENT
Topic
Name
9+8 =