I am using the following code to parse XML data from a Google Calendar feed:
require_once('coreylib/coreylib.php');
$calendar = variable_get('calendar_id_setting');
$now = date('Y/m/d', strtotime('now'));
$next_week = date('Y/m/d', strtotime('+7 days'));
$api = new clApi('http://www.google.com/calendar/feeds/' . $calendar .'/public/full?singleevents=true&min-start=' . $now . '&max-start=' .$next_week);
if ($feed = $api->parse()) {
foreach($feed->get('entry') as $entry) {
error_log($title . ' ' . strtotime($entry->get('when@startTime')));
The problem is in the error log my first result is a unique event with correct title and time, but the following 25 results all have the same title and have a start time in 2026(?!).
All but one of the events are recurring events. I thought setting ‘singleevents=true’ on the URL would solve this problem but apparently not! What is the correct fix here?
Compare your URL with the one in the Calendar API v2 documentation. You’re providing parameters
min-startandmax-start, in a format of'Y/m/d'. The documentation shows an example with parameters ofNote the use of
start-minandstart-max, and a format ofyyyy-MM-dd'T'HH:mm:ss. Given the parameter reference I suspect you could get away with justyyyy-MM-dd, but you should follow that format rather than using slashes and single-digit versions.Of course that doesn’t quite explain the results you’re getting in 2026, but using the right parameters would be a good starting point.
Additionally, you may wish to consider using the v3 API and possibly the PHP (beta) client library.
(Note: although I work for Google and used to use the client API myself, this answer is provided purely in a personal capacity.)