Home › Forums › Calendar Products › Events Calendar PRO › Today’s events code shows today’s and tomorrow’s events
- This topic has 13 replies, 4 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
July 8, 2012 at 5:53 pm #21722
Richard
MemberGreat 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.1July 9, 2012 at 10:48 am #21750Jonah
ParticipantHi 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,
JonahJuly 9, 2012 at 12:04 pm #21770Richard
MemberJuly 11, 2012 at 8:28 am #21952Jonah
ParticipantHi 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,
JonahJuly 12, 2012 at 9:51 am #22002Richard
MemberOk. 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
July 12, 2012 at 11:13 am #22016Rob
MemberGreat 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!
July 15, 2012 at 12:34 pm #22134Richard
MemberHey 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.
July 18, 2012 at 7:20 am #22260Rob
MemberHey Richard. Interesting question; not sure about this myself, but let me see what Jonah has to say. Stay tuned.
July 18, 2012 at 7:51 am #22279Jonah
ParticipantHi 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
July 18, 2012 at 1:29 pm #22307Richard
MemberThanks again, guys!
July 18, 2012 at 4:17 pm #22315Jonah
ParticipantAwesome, so did that work Richard?
July 23, 2012 at 8:06 am #22559Richard
MemberNot 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.
July 23, 2012 at 8:13 am #22560Jonah
ParticipantSounds good Richard 🙂
July 7, 2015 at 6:25 am #977493Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Today’s events code shows today’s and tomorrow’s events’ is closed to new replies.
