Display based on date

(paul walker) #1

Hi Folks
[Squiz Matrix v5.5.6.4]
I have built a custom content container to display selected calendar events on a page.
The idea is that the event is displayed up until, and including, the start day of the event. The Event should be hidden the following day
The following code works fine but hides the event on the start day (rather than a day later).


I have tried numerous ways of manipulating the dates to no avail - would anyone have any suggestions?

Thank you for your time

(Hugh McMaster) #2

You’re not accounting for minutes in this date comparison.
%event_start_date% returns the date, but it also has a time component (usually just past midnight on the day), even if it’s not shown.

%globals_date% returns the current date and time, as you’d expect.

So, in your comparison for the day of the event, the current day/time is almost always going to be more recent (‘greater’) than the event time. And the ‘equal to’ part of the gte_date modifier only checks for comparison at the exact time.

You need to format the current date/time as a date only for this comparison, and use braces, since your implementation is likely to break in certain circumstances.

%event_start_date^gte_date:{globals_date^date_format:Y-m-d}% is the syntax.

(paul walker) #3

Sir, you are a star and I shall take full credit for your cleverness :slight_smile:
Not really,
Truly thank you very much - I did try to play with the date format but clearly was not clever enough to work it out - now it is working splendidly
thankyou, thankyou