I built a view to show the three latest events, including today's event on the home page.
Link to a page where the issue can be seen: Site Home Page
After implementing the workaround in #1117132 https://toolset.com/forums/topic/date-comparison-error-with-tribe-events-calendar-after-update/, the filtering is working ok, except that it doesn't show today's events. My current filter is: _EventStartDate is a DATE greater than or equal TODAY()
I've also tried:_EventStartDate is a DATE greater than or equal PAST_DAY(1), but it still won't show today's event.
Try change DATE to NUMBER, that should solve this issue.
If not, then it is due to this, likely:
https://toolset.com/forums/topic/date-comparison-error-same-as-post-1116145/
If so, please let us know, since we would need to analyse this, and not simply close the ticket as done there, with the statement that it does "not work".
We do not do that usually @Toolset. We help or at least try to until the issue is either clear or solved.
Please let me know how above tests go, and if you use the Plugin (I cannot see it on your Debug info, hence I think after changing to NUMBER; the issue should be solved)
Hi Beda,
I changed DATE to number, but that results in no output at all (No Items Found).
I've also changed the event dates ahead 1 day (works as expected - the event shows) and experimented with various combinations of DATE, number, TODAY, NOW, PAST_DAY(1), FUTURE_DAY(-1), etc. to no avail.
It seems that the problem lies with the interpretation of relative dates such as TODAY and NOW because even setting the filter in the view to _EventStartDate is a DATE greater than or equal THIS_MONTH() should show any event of this month, before or after the current day, but still only shows events in next month.
Hi,
Thanks for the details, I can login your website, please point out the problem page URL and view URL, where I can edit your PHP codes, I need to test and debug in a live website.
Sorry for the delay. The issue exists on the front page. About 1/3 down you'll see the 3 most recent calendar events showing.
The view: hidden link
A demo event you can work with: hidden link
Right now (9:00am GMT -7) I am able to set an event for today that starts at 4:01pm and it shows correctly. However, in one minute, at 9:01am, the event drops off. Ideally, I'd like the events to stay visible until midnight of the day of the event, regardless of the start time of the event. For example, if I have an event today at 3pm, I'd like the event to show until today at midnight, then drop off.
Thank you very much for your assistance.
Thanks for the details, I assume we are talking about the custom PHP codes in your website:
hidden link
As you can see it is applying custom filter to field "_EventStartDate", so you don't need to setup filter on the same field in view UI.
I have done below modification in your website:
Edit the view "FP Events View", in section "Query Filter", remove the filter on "_EventStartDate", please test it again.
Thank you Luo, unfortunately that didn't solve the issue. The events are still expiring 7 hours prior to the event start time. I experimented in the custom PHP code with the type (date, number, string) and operator (> and >=) with no luck, however, changing the operator to < does show events prior to today, but <= also does not show today's event. Curiously, using != returns only past events. Using just = as the operator returns no results at all, but I would expect it to show only today's event.
Thanks for the clarification, it should be a problem timezone problem, if I am right, your web server is using different timezone setting from your wordpress setting:
Dashboard->Settings-> General, option "Timezone"
In your case, you can modify the PHP codes from:
hidden link
...
'value' => date("Y-m-d H:i:s"),
...
To:
...
'value' => date("Y-m-d H:i:s", current_time( 'timestamp')),
...
More help:
hidden link
timestamp
The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().
https://codex.wordpress.org/Function_Reference/current_time
Returns the blog's current local time in the specified format.
That fixed it almost perfectly! I want the events to expire at midnight on the day of the event, not at their start time so building on what you wrote, I did the following:
I defined timestamp as a variable for midnight, instead of the current time:
$timestamp = strtotime('today midnight');
Then used that variable instead of 'timestamp':
'value' => date("Y-m-d H:i:s", current_time($timestamp)),
I'll be testing it for a few days, but I do believe that it works exactly as it should now. Thank you!!