Hi,
I have two dates fields datedebut and datefin and I have to check if this event is still avaible today.
I was sure to get the correct comparison, but some “present” events are not viewed like “present”, and some “present” events would not have to be “present”…this is my code :
Well, you are only checking the end date, not the start date… So you should actually check if the start date is prior or equal to today and. the end date still in the future. While future events have a start date and end date in the future.
You should not use strftime here. Currently you compare the strings with %d.%m.%y that does not work here. For example: '20.10.2018' < '21.09.2018' will be true.
You should simply use the unix timestamp to compare the dates.
There was also an error with … && $today >= $expire should be … && $today <= $expire.
What would be an adequate Kirby 3 solution for this? I am trying to use the answer above but I only get a “Object of class Kirby\Cms\Field could not be converted to int” error…