Hi, I added visitbility condition in one of my section on my website. The condition are date after dec 12 and time after 8am for example. It is working but it is resetting everyday. Im not sure what time it resets but it disappear after some time and will reappear after 8am on another day. It should always appear after it mets the condition right.
Set the Include type to OR
setting it to or will show even the date is before the date.
@kris what do you want to achief?
After this date you want after 14:00 show a pop-up, and befor 14:00 not?
Of do you want to show a popup after this date-time and show it all days?
Check the time it is comparing to, this is usually the server time.
so basically after the time and the date in the condition, i want to show it all the time. example before december 12 8am, i dont want to show the section. but after december 12 8pm, i want it to show all the time.the condition i added works but it was resetting after some time if i dont remove the condition after dec 12 8am
I think we can assume this is correct behaviour and the Time condition is activated after the specified time every day after the specified date.
If that is the case, then ideally we need a feature request for a DateTime condition that will do what you are requesting.
In the meantime, you can use a function similar to this instead:
function isDateTimePast(dateTimeToCheck) {
return (new DateTime() > new DateTime(dateTimeToCheck));
}
Then call it from your visibility condition like this:
isDateTimePast("2024-05-15 16:00:00")
Notes:
- If you use this approach the string you pass must be a valid string accepted by the DateTime constructor
- You must define your function before you can use it
Feature request:
thank you @StrangeTech . will definitely try this one.
@kris see the answer of StrangeTech,
But here is some explanation why your solution didn’t work.
You used the AND function in the two conditions.
So it had to be visible after that specific date AND the time has to be afther a specific time.
With the AND function, both the conditions have to be true otherwise it doesn’t show.
If it is after that date, but not after that time, the AND function returns false.
Whilst this is true, changing it to OR would not help.
If OR was used then it would be visible if:
- after the chosen date
OR - after the chosen time (on every date)
Which is not the desired behaviour.
That is is why the feature request is a useful one.
Thanks @StrangeTech for explaining the OR too.
Multiple functions and brackets would help too to create more complex conditions.
Not only AND or only OR but something like (condition 1 AND condition 2) OR condition 3
And thanks for making the feature request, I upvoted that one.
Agreed!
If you want to, you can weigh in with your thoughts in that thread