We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,415 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Pulling events from Google Calendar?

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--

2
Contributors
3
Replies
1 Day
Discussion Span
3 Months Ago
Last Updated
9
Views
Ryujin
Light Poster
26 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@Ryujin

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

Did you write that code?

The code you provided doesn't look like the example at google (I think you modify it and now you can't figure how to pulling the event)?

Just follow the code:

https://developers.google.com/google-apps/calendar/v1/developers_guide_javascript

LastMitch
Industrious Poster
4,204 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

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.

Ryujin
Light Poster
26 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

LastMitch
Industrious Poster
4,204 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0608 seconds using 2.71MB