ACF Date Conditional Logic Issue

Hi folks,

Woof. This has stumped me. I’ve spent a lot of time trying to figure out what’s going on, thought I’d figured it out, then discovered I hadn’t.

The logic is really, really simple.

If {{Event Date}} is in the future, Display element (Layout, Coming Soon tag, etc.)

I’ve tried using the Conditional Logic Date Function with the below argument:

{{dc:acf:post_field field=“event_date”}} AFTER {{dc:global:date}}

The only thing that seems to work is to change the ACF date return format to “Ymd.” But then we output an awful number and there doesn’t seem to be a way to re-format the ACF Date? Can we re-format the ACF date? Do I just need to have two date fields: Ugly date and Pretty Date?

Help.

Hello @lukefinsaas,

Thanks for writing to us.

Please have a look at this thread for reference.

Hope it helps
Thanks

@prakash_s, can you give me access to the thread or make it public? Thread appears to be a private post. Tried to get at it a few ways:

Hi @lukefinsaas,

You need to log in to your Themeco Account to see the thread referred by my colleague.

Thanks

Hey @tristup,

Yeah, I was logged in. Not sure what else I need to do?

Hi @lukefinsaas,

I have checked the reference thread and found that is the Beta testing thread and that might be the reason why you are not able to access it. Coming to your issue, I would suggest you use {{dc:acf:post_field field="event_date" type="date" format="YmdHi"}} and {{dc:global:date format="YmdHi"}} to compare the data in the same format. You can add the following code into a Text element to understand what value is returned by these two Dynamic Content tags.

Event Date: {{dc:acf:post_field field="event_date" type="date" format="YmdHi"}}<br/>
Global Date: {{dc:global:date format="YmdHi"}}

If that does not help, please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password
– Specific Page where you are having the problem with this

To create a secure note, click the key icon underneath any of your posts.

Thanks

Closer, I think, but still getting a really strange output:

I’ll pass some credentials in a secure note.

Also, I stripped off the Hi from Ymd as the custom field is just a date picker, not date and time. (Didn’t seem to make a difference either way.)

Hello @lukefinsaas,

To be able to display the date in a readable way, like Feb. 18, 2022, you can use:

Event Date: {{dc:acf:post_field field="event_date" type="date" format="M. d, Y"}}<br/>
Global Date: {{dc:global:date format="m d Y"}}

By the way, I could not find where you have added the condition.

Best Regards.

Sorry, I wasn’t clear.

You can see from the screenshots that my ACF event date is set as 2/26/2022 — so it should output 20220226, not 20220217.

Today that field is outputting 20220228, meaning that it’s just reflecting the Server date?

Then the next event down, the post is set for June 22, 2001 but on the post, it’s set for January 6, 2022.

20010622 vs 20220106

Suspicious, right?

This made me think that I need to change the return array on the ACF field. Seems like it’s scrambling the output, despite our insistence to the contrary.

And yes, that’s it.

With your help on the format question, I can swap around the logic there and we’ll be all good

BUT! Your "format= insight will make this easier, I think.

Moral of the story — for all you Future Forum Traveler (likely myself) — return the Array in the standard server format (‘Ymd’) and then transform the output via this method:

{{dc:acf:post_field field=“event_date” type=“date” format="[ whatever you please — here’s WP date formatting for quick reference ] "}}

2 Likes

Hey @lukefinsaas,

I believe that you have already figured it out! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

Yep! Slick once I was able to reformat both sides of the date field (server + ACF).

One last note for other Forum searchers:

This BEFORE / AFTER toggle works great — except on the actual DATE.

Yikes! Then both layouts turn off, as neither of them are Before or After the Date.

The work around is to use Numbers, rather than Date. Reformat server time to “Ymd” and then you can compare the numbers, and set one to run when they’re equal.

Hi @lukefinsaas,

Thanks for sharing your ideas! If you have any other concerns or clarifications regarding our theme features, feel free to open up new thread.

Thank you.

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