user974552
user974552

Reputation: 193

Google Calendar API - Updating an Events start & end date/time

The sample/demo code for Google's API is pretty clear about updating an event title, and it seems like everyone loves copying it into their own tutorials... I can use that example to easily update the title, description, and location of an event, but I cannot use it to update the "when" attribute, which is made up of an array with start and end date/time.

The following code does not return an error but it does not update the date and time as well:

if ($eventOld = getEvent($client, $eventId)) {
        //echo "Old title: " . $eventOld->title->text . "<br />\n";
        $eventOld->title = $gdataCal->newTitle($title);
        $eventOld->where = array($gdataCal->newWhere($where));
        $eventOld->content = $gdataCal->newContent("$description");

        $eventOld->when[startTime] = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
        $eventOld->when[endTime] = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";

        print $startDate;

        try 
        {
            $eventOld->save();
        } 
        catch (Zend_Gdata_App_Exception $e) 
        {
            var_dump($e);
            return null;
        }
        //return $eventNew;
    }
    else 
    {
        return null;
    }

Upvotes: 0

Views: 1890

Answers (2)

Lewis
Lewis

Reputation: 21

You're submitting to the wrong var. $eventOld is previous to make changes create a new var. Then submit your data for ex.

$eventNew = getEvent($client, $eventId)
$eventNew->when[startTime] = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
$eventNew->when[endTime] = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";

Upvotes: 2

user663031
user663031

Reputation:

when is an array of startTime/endTime pairs.

Upvotes: 0

Related Questions