Today’s events code shows today’s and tomorrow’s events

Home Forums Calendar Products Events Calendar PRO Today’s events code shows today’s and tomorrow’s events

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #21722
    Richard
    Member

    Great plugin, but I’m having this issue.

    Using this code to show today’s events only on the home page:

    global $post;
    $CurrentDate = date(‘Y-m-d’);
    $events_today = tribe_get_events(
    array(
    ‘start_date’=>$CurrentDate,
    ‘end_date’=>$CurrentDate,
    ‘eventCat’ => 102,
    )
    );
    foreach($events_today as $post) {
    setup_postdata($post);

    The problem is that at 8pm, it shows the next day’s events as well as the current date’s events. At first I thought it might be a timezone issue as the shared server is PDT while I am EDT, 3 hours ahead. The fact that it shows both days, though, seems to be a different problem.

    I tried editing the .htaccess and changing the WordPress site to PDT to no avail.

    Note that all events in question end before midnight on the start_date.

    Help on this issue would be greatly appreciated as we’re misinforming people when the events show up under “Happening today at…”

    Thanks!

    ECP/TEC 2.07
    WP 3.4.1

    #21750
    Jonah
    Participant

    Hi Richard,

    Just to make sure I have all the code to be able to test this can you please post your code to pastie.org or pastebin.com

    Thanks,
    Jonah

    #21770
    Richard
    Member

    Here’s the link… http://pastebin.com/B3rcppmC

    Not sure if embedding works:

    Thanks!

    #21952
    Jonah
    Participant

    Hi Richard,

    I haven’t been able to reproduce this yet and I’ve tried switching around the times of the event on the next day to try and “break” the query and get the 2nd event to show. I haven’t tried looking at it specifically at 8pm but will do so as soon as I can. Can you please try deactivating all other plugins and switching to the Twenty Eleven theme to rule out a conflict with another query somewhere else?

    Thanks,
    Jonah

    #22002
    Richard
    Member

    Ok. I’m testing this on a dev subdomain, theme twentyeleven, all other plugins deactivated.

    I’ll find out at the magic time (8pm Eastern Daylight Time) and let you know what happens.

    Thanks.

    Richard

    #22016
    Rob
    Member

    Great to hear, Richard – thanks for confirming as much. We’ll watch for your response here and will follow-up as needed from there. Thanks for your patience so far!

    #22134
    Richard
    Member

    Hey guys. I fixed my issue. It was, indeed, a timezone problem. The MySQL server said PDT, but echoing the timezone on a test page produced “UTC,” 4 hours behind EDT.

    This line of code within the loop variables solved it…

    date_default_timezone_set(‘America/New_York’);

    The only thing now is that we have to set our events to end before midnight for it to display correctly. A lot of our events end after midnight, so it would be great to put a more realistic ending time.

    Would you guys or anyone else happen to know to achieve this if I wanted to extend the end_date 3 hours to 3 a.m.?

    I tried this:

    $EndDate = date(‘Y-m-d’, strtotime(‘3 hours’));

    didn’t work. Maybe ’27 hours’? I’m not sure how or even if it works in conjunction with the multiple day cutoff time.

    Thanks for setting me on the right path.

    #22260
    Rob
    Member

    Hey Richard. Interesting question; not sure about this myself, but let me see what Jonah has to say. Stay tuned.

    #22279
    Jonah
    Participant

    Hi Richard,

    You might want to look at the documentation for strtotime here: http://php.net/manual/en/function.strtotime.php but changing the parameter to ‘+3 hours’ should work…

    – Jonah

    #22307
    Richard
    Member

    Thanks again, guys!

    #22315
    Jonah
    Participant

    Awesome, so did that work Richard?

    #22559
    Richard
    Member

    Not quite. I’m going to mess around with it some more using a test page.

    I’m going to read up on DateInterval and see if this will help. If I get it working I’ll post the solution.

    #22560
    Jonah
    Participant

    Sounds good Richard 🙂

    #977493
    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 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Today’s events code shows today’s and tomorrow’s events’ is closed to new replies.