Show/hide content using date and time conditional

Hi team,

I’m needing to hide content at a specific time on a specific day (8:30am on the 16th of October 2023). My initial attempt to set up the conditional looks like this but doesn’t seem to be working:

{{dc:global:date format=“Y-m-d H:i:s”}} before 2023-10-16 08:30:00

I found this thread which suggests separating date and time like so:

{{dc:global:date format="Y-m-d"}} before 2023-10-16
{{dc:global:time format="H:i:s"}} before 08:30:00

However this doesn’t work either as it hides the content on all dates prior to the stated time rather just hiding it at that time on the specified date.

Where am I going wrong?

Thanks in advance for your wisdom and advice!

Hello @liquidedge,

Thanks for writing in!

This condition:

means that the element will show only before the said date and time. If you want to display the element on that particular time and date, you should use the String condition instead:

Best Regards.

Thanks for your advice @ruenel.

Yes, the first example is what I’m trying to achieve, but the logic doesn’t seem to work because it checks the date and time parameters separately. So for all the dates prior to 2023-10-16 it stops showing the element after 08:30:00 because both parameters must be simultaneously true.

Is that making sense?

Hello @liquidedge,

You can use the OR logic so that for all the dates after 2023-10-16 it stops showing the element OR if the time of the day is after 08:30:00.

Can you please elaborate on your condition?

Thanks.

Sorry, I don’t think OR logic will work either, for the same reason: If the date and time conditions are checked separately, the element will continue to display after the prescribed date has passed simply because the prescribed time has not yet passed. Sorry, I know this sounds confusing.

Good news, I’ve solved it!

It turns out the thread I referred to above was misleading or possibly plain wrong. It is in fact possible to reference both a time and date for {{dc:global:time}}. The problem was that they (and I) were using the wrong kind of speech mark when trying to specify the format.

  • This works: {{dc:global:time format="Y-m-d H:i:s"}}
  • This does not work: {{dc:global:time format=“Y-m-d H:i:s"}}

Whew, glad to get this sorted out. Thanks for bearing with me.

1 Like

Hi @liquidedge,

Glad that you were able to solve it.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.