Home › Forums › Calendar Products › Event Aggregator › Imported event has different time than Facebook event
- This topic has 10 replies, 2 voices, and was last updated 11 years ago by
Barry.
-
AuthorPosts
-
March 27, 2015 at 2:51 am #951383
Adam
ParticipantHi there
I am getting a problem with events imported automatically from Facebook where the time doesn’t match.
This does just seem to be on events after the clocks change in the UK to BST, which happens on Sunday.
I’ve checked through various threads and see the answer is normally the timezone in WordPress, however, this is correct and set to London, and has not been changed.
Any ideas?
Thanks
Adam
March 27, 2015 at 8:26 am #951505Barry
MemberHi Adam,
I’m sorry to hear you are hitting difficulties.
Certainly if the difference is exactly an hour in each case your theory about the change to summer time seems like a plausible one. I wonder if you can you confirm a couple of things for me:
- When you say your WordPress site is set to London time, do you mean “Europe/London” or are you using an offset such as “UTC +0”?
- Can you provide the Facebook URL for one of the events in question so we can double check if it is set to, for example, GMT (in which case the adjustment would be expected)?
Thanks!
March 27, 2015 at 8:44 am #951511Adam
ParticipantThis reply is private.
March 27, 2015 at 9:12 am #951521Adam
ParticipantThis reply is private.
March 27, 2015 at 9:22 am #951522Barry
MemberOK, so those events all seem to be set to UTC or UTC+1 (mostly the latter).
GMT time is 2015-03-27 15:33:14 Local time is 2015-03-27 15:33:14
Unless I’m mistaken, BST is equivalent to UTC+1 and GMT is effectively the same us UTC. Is it the case that this issue surfaces only for the events set (on Facebook) to UTC+1? The adjustment would certainly be the expected behaviour in such a case, as your WordPress site appears to be operating in GMT.
March 27, 2015 at 9:23 am #951523Barry
MemberApologies, I missed your followup:
Also, am I right in thinking that once an event is imported it does not update to match any changes made to the event on Facebook, i.e. if the start time is changed on Facebook, it doesnβt automatically change in WordPress?
That’s correct.
March 27, 2015 at 9:28 am #951526Adam
ParticipantThis reply is private.
March 30, 2015 at 7:20 am #951843Barry
MemberHi Adam,
Just a note first of all that private replies are absolutely fine and we understand customers don’t always wish to publicly expose URLs, etc, but for general questions containing no sensitive information whatsoever it is helpful if you do not mark them private (doing so reduces the usefulness of forum topics like this one to other users in the future) π
Do you have any guidance as to how I can fix the time difference problem?
For those events that have already been imported I can only suggest editing them and making the adjustment per event.
For any events you import in the future it is possible to modify things like the date/time information before it is saved to the database by using the following hook:
tribe_fb_parse_facebook_eventYou could then “correct” the EventStartDate and EventEndDate fields where necessary. Do be aware though that if the source events use a variety of timezones then the lack of conversion can cause unusual effects, such as an event disappearing from the upcoming event list too soon (or staying too long), depending on whether the source timezone was ahead or behind your local WordPress timezone.
One other note is that if you would like to see a setting added to turn off automatic timezone conversion we’d certainly be open to implementing that – please just post a request here or else add your support to any suitable existing requests π
March 30, 2015 at 7:33 am #951848Adam
ParticipantHi Barry
Thanks, apologies about the private reply, I’ll know what to do in future π
Sorry if I’m being dumb, but where do I add this ‘hook’ (tribe_fb_parse_facebook_event)?
Cheers
Adam
March 30, 2015 at 8:04 am #951868Barry
MemberNo problem – that’s a great question.
There are actually a number of places you can add it – from your theme’s functions.php file to a custom plugin – the best place to learn about this aspect of WordPress development is actually the WordPress Codex itself (lots of people find their theme’s functions.php file to be the easiest location for them).
I’m thinking what you’ve requested might be useful for others out there, too, so here’s some sample code you can try:
add_filter( 'tribe_fb_parse_facebook_event', 'no_fb_timezone_conversion' ); function no_fb_timezone_conversion( array $params ) { $src_event = Tribe_FB_Importer::instance()->get_facebook_object( $params['FacebookID'] ); if ( 'yes' === @$params['EventAllDay'] ) return $params; if ( ! isset( $src_event->end_time ) ) $src_event->end_time = $src_event->start_time; $start_time = new DateTime( $src_event->start_time ); $end_time = new DateTime( $src_event->end_time ); $params['EventStartHour'] = TribeDateUtils::hourOnly( $start_time->format( TribeDateUtils::DBDATETIMEFORMAT ) ); $params['EventEndHour'] = TribeDateUtils::hourOnly( $end_time->format( TribeDateUtils::DBDATETIMEFORMAT ) ); return $params; }Suppose your site operates in GMT and you import an event taking place at 5pm in Beijing: this will force the event to import as if it were taking place at 5pm GMT (and I’m giving such an extreme example just to help highlight the way it works to anyone else coming across this topic).
To workaround summer time/winter time issues, though, it should hopefully do the job π
April 20, 2015 at 7:07 am #956636Barry
MemberHi!
It’s been a while so I’m going to go ahead and close this topic.
- Need help with anything else? Go right ahead and post a new topic, one of the team will be only too happy to help
- Still need help with this issue and need to re-open it? Again, please simply create a new topic and link to this one to provide the team with some context
Thanks!
-
AuthorPosts
- The topic ‘Imported event has different time than Facebook event’ is closed to new replies.
