Getting tribe_get_events() to work with timezones

Home Forums Calendar Products Events Calendar PRO Getting tribe_get_events() to work with timezones

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1044121
    James
    Participant

    Hi everyone,

    I’m retrieving a list of upcoming (and ongoing) events:

    date_default_timezone_set('Europe/London'); 
     
    $now = new DateTime();
     
    $events = tribe_get_events( array(
        'eventDisplay'   => 'upcoming',
        'start_date' => $now->format('y-m-d H:i')
    ) );
     
    $event = new DateTime(tribe_get_start_date( null, true, "y-m-d H:i:s"));
    $end = new DateTime(tribe_get_end_date( null, true, "y-m-d H:i:s"));

    For tribe_get_events(), the cutoff for an event is if its end_date is before the above start_date.

    Now here is my problem. This is the output I get:

    $now: 15-12-19 04:54
    $event: 15-12-19 03:00
    $end: 15-12-19 06:00

    As soon as $now reaches 05:00, this event disappears, no longer gets retrieved by tribe_get_events(). It should be cut off at 06:00 (the end time), but cuts off at 05:00.

    Now this may be because I’m working in a particular timezone, Europe/London, which has a +1 offset. If this is the case, how do we get the function to adhere to timezones?

    If that’s not the issue, what could it be?

    Thanks!

    #1044827
    James
    Participant

    Any help with this please?

    #1044980
    George
    Participant

    Hey James,

    We unfortunately cannot help with custom coding projects 🙁 Furthermore, our support hours are only Monday through Friday, and our goal is to get replies to folks within 24 hours. So apologies for the delayed response over the weekend!

    Despite us not being able to help with custom code, I’m curious – why are you explicitly stating the timezone here instead of just letting WordPress handle the timezone? It’s odd to see you using date_default_timezone_set(‘Europe/London’) – why not just go to Settings > General in your site’s wp-admin and set the timezone there to London, and then remove this date_default_timezone_set() function call?

    Thanks,
    George

    #1076346
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Getting tribe_get_events() to work with timezones’ is closed to new replies.