1.11M Members

Pulling events from Google Calendar?

 
0
 

We list our daily opening/closing hours on a Google Calendar as Events. After some struggles with the Javascript API, we are almost able to extract the hours (events) for today and for tomorrow to embed elsewhere on the site -- but at 7pm local time (EST in the US) it kicks over to the next days' listings.

That seems to be 0:00 GMT, when it switches, yet the calendar itself displays as it should for our time zone. For some reason I'm too dumb to find, the script is pulling the events in a way that almost does does but doesn't quite correspond with the calendar.

Any ideas on how to solve this? (I'm open to even inelegant workarounds.)

Not sure, but suspect the relevant script chunk is below:

/* loop through each event in the feed */
  var len = entries.length;
  for (var i = 0; i < len; i++) {
    var entry = entries[i];
    var title = entry.getTitle().getText();
    var startDateTime = null;
    var startJSDate = null;
    var times = entry.getTimes();
    if (times.length > 0) {
startDateTime = times[0].getStartTime();
      startJSDate = startDateTime.getDate();
    }
    var dateString = (startJSDate.getMonth() + 1) + "/" + startJSDate.getDate();
if (!startDateTime.isDateOnly()) {
  dateString += " " + startJSDate.getHours() + ":" + 
      padNumber(startJSDate.getMinutes());
      }

Thanks very much--

 
0
 

We are pulling the events. What we don't understand is how to fix the 5-hour offset.

If user sees the event we pull right now (Sunday at half-past six in the morning) it's fine, it shows our hours for Sunday. Same deal at noon. And at 4pm, and so on--up until 7pm, when it will instead show the hours for Monday.

Thanks.

LastMitch
Deleted Member
 
0
 

@Ryujin

If user sees the event we pull right now (Sunday at half-past six in the morning) it's fine, it shows our hours for Sunday. Same deal at noon. And at 4pm, and so on--up until 7pm, when it will instead show the hours for Monday.

This is issue you are having is more related to the server:

http://phpmaster.com/working-with-dates-and-times/

Here is a list of timezones:

http://www.php.net/manual/en/timezones.php

To fixed that issue you need to create a php.ini file and put this:

date.timezone = "America/Belize" 

And used this date_default_timezone_set function as a php:

http://php.net/manual/en/function.date-default-timezone-set.php

date_default_timezone_set('America/Belize');

that will solve the issue you are having.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: