Forum Replies Created
-
AuthorPosts
-
andrew82
ParticipantI had UTC Brian! I’ve been working with WordPress for 6 years or so and never had to set the date via the WP admin, and if I knew that was there I would been the first to check it. Thanks for all your help!
It seems like everything works fine, I’ll watch an event expire in the next hour and make sure I get the notice ‘this event has passed’.Thanks for your help and determination!
andrew82
ParticipantHi Brian, Thanks alot for writing that up. I pasted that code into my set_notices() and got the following output
gmt offset: +0
event end time actual: 2015-01-09 19:30
event end time with offset (+5 from actual endtime): 1420831800 = 2015-01-09 19:30:00
current time GMT (+5 from east coast): 1420837612 = 2015-01-09 21:06:52I’ve put a screenshot here for you for further reference if you want to see it on the page.
My coding chops are not wicked great, but I believe there is still a problem.
andrew82
ParticipantHi Brian, My previous post shows that I sorted out the issue with events showing their end time as their start time. It was the
'key' => '_EventEndDate',in my code above which needed to be changed to'key' => '_EventStartDate',The issue with the event’s showing to be passed, at the event level itself is still happening though and the time offset is 5 hours, which is the difference between EST in North America and GMT. Calling the date() function as in the single-event.php as below..
echo 'Now: '. date("F j, Y, g:i a") ."\n";gives me GMT time instead of my local timezone. I’ve added ‘-5’ as the value in the GMT offset of the set_notices() function in the single-event.php in the the-events-calendar/lib/template-classes folder. And it does not change the above output, so it’s still reading GMT time. I am using events calendar pro and I also have my own template for single-events in my theme in the ‘tribe-events’ folder.
Any idea how I can get things running on my local timezone?andrew82
ParticipantEither I love answering my own questions or I don’t give myself enough credit to sort it out myself. The issue with events showing at their end time, instead of start time (something folks at the studio didn’t like much) was due to
'key' => '_EventEndDate',in my code. Of course changing this to EventStartDate takes care of that problem wonderfully.The remaining issue is that the singular event listing is still showing itself passed so it’s labeled with a ‘This event has passed’ in blue above the event when it is still to take place. Obviously my New timeDate() is only active on the homepage. So the bigger question is why is Events Calendar Pro operating on UTC time when we are in EST North America? And if I can correct it on my homepage with a New timeDate() call, do I have to do it everywhere else?
A live link to the site: http://www.swandojo.com
andrew82
ParticipantOk, So everything worked fine for a while, or as I thought. But it seems like there is still a big issue with this. The homepage event listing is now showing that the events start at their prescribed end time. So if the event runs from 6-7pm it’s showing on the homepage that it starts at 7pm. Some unhappy campers with the event attendees so far 🙂 Furthermore Its seems as if only on my homepage is the new DateTime(); active. Therefore if you click on the event for further details, the event post itself shows that warning ‘This event has passed’ in blue at page top when it should not be passed. Here’s my custom call for events on the homepage template
add_filter('tribe_events_pre_get_posts', 'filter_tribe_all_occurences', 100); function filter_tribe_all_occurences ($wp_query) { if ( !is_admin() ) { $new_meta = array(); date_default_timezone_set('America/New_York'); $today = new DateTime(); // echo $today->format('Y-m-d H:i:s'); // Join with existing meta_query if(is_array($wp_query->meta_query)) $new_meta = $wp_query->meta_query; // Add new meta_query, select events ending from now forward $new_meta[] = array( 'key' => '_EventEndDate', 'type' => 'DATETIME', 'compare' => '>=', 'value' => $today->format('Y-m-d H:i:s') ); $wp_query->set( 'meta_query', $new_meta ); } return $wp_query; } ?> <?php // Calls Events from Events Calendar $posts_array = tribe_get_events( $full = false ); foreach ( $posts_array as $post ) : setup_postdata( $post ); ?> <div id="post-<?php the_ID() ?>" class="<?php tribe_events_event_classes() ?>"> <?php tribe_get_template_part( 'list/single', 'event' ) ?> </div><!-- .hentry .vevent --> <?php endforeach; ?>andrew82
ParticipantHi Brian,
Thanks for the tip. It seems like new DateTime(); produdes a time which is 5 hrs (not 2) ahead of our current timezone. I would have tried to echo that previous to posting first, but I could get echo $today; to work as DateTime has a specific format which needs to be called to echo as I’ve figured out in the PHP Manual. In this case instead of adding or subtracting time to even it out I used the date_default_timezone_set(‘America/New_York’); and the America/New_York timezone to set the timezone to EST here in the U.S. I called this function just before the new DateTime function in the code above. like this..if ( !is_admin() ) {
$new_meta = array();
date_default_timezone_set(‘America/New_York’);
$today = new DateTime();
echo $today->format(‘Y-m-d H:i:s’);And the time is currently being set at the right timezone (instead of UTC). So I think this should be good. Once I see the events ‘expire’ from the homepage at the right time this evening I’ll post to confirm everything is all good!
-
AuthorPosts
