Imported event has different time than Facebook event

Home Forums Calendar Products Event Aggregator Imported event has different time than Facebook event

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #951383
    Adam
    Participant

    Hi 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

    #951505
    Barry
    Member

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

    #951511
    Adam
    Participant

    This reply is private.

    #951521
    Adam
    Participant

    This reply is private.

    #951522
    Barry
    Member

    OK, 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.

    #951523
    Barry
    Member

    Apologies, 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.

    #951526
    Adam
    Participant

    This reply is private.

    #951843
    Barry
    Member

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

    You 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 πŸ™‚

    #951848
    Adam
    Participant

    Hi 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

    #951868
    Barry
    Member

    No 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 πŸ™‚

    #956636
    Barry
    Member

    Hi!

    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!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Imported event has different time than Facebook event’ is closed to new replies.