I currently have a Date + Time field, which works as intended, but the issue comes from trying to show a message if the date is TODAY. The issue I’m having is it's taking the TIME into consideration when comparing the value, rather than the day as a whole.
The message/conditional below only shows IF it is the day AND on or past the time value, which isn't good for me as need the message up all day from midnight. I can't set the time to 00:00 as it needs to display the correct time e.g. 19:00.
[wpv-conditional if="( $(wpcf-draw-date) eq 'TODAY()' )"]
Draw is today!
[/wpv-conditional]
^ Is there a way to ask it to ignore the time when comparing the date, as this only shows the message if it's on or past the time as well as the day.
Once you create the code snippet within the "Custom Code" section, make sure to activate it and then also register the shortcode name draw_date_only at:
=> Toolset => Settings => Front-end Content tab => Functions inside conditional evaluations section.
Then you can compare it as:
[wpv-conditional if="( '[draw_date_only]' eq 'TODAY()' )"]
Draw is today!
[/wpv-conditional]
Thank you kindly for your assistance, I've gone ahead and added the code in the relevant places (see screenshots) - but it's not being shown on the front-end.
I've also set the "Time" to a few hours ago (just to test), but it still doesn't show.
The wpcf- field is correct the Toolset shortname is draw_date, so not sure what is happening. - Any ideas, please?
Yes, that's correct we show labels on various products depending on the date/time entered...the 3 x scenarios would be:
1. Show the Date + Time of a particular Date (normal) e.g ."June 20th 2026 at 15:00pm"...
2. IF the Date (day) is the same day as the selected date/day via the picker, then show "This message instead" e.g. "Today is the day"...
3. IF the Date has passed, then show "a third message" instead e.g. "Closed".
These conditionals/results are what I’m ultimately trying to achieve, and hope you'll be able to help.
Please see the attached. - To reiterate, what you've said is true, and I imagine if I just had a date field, then it would be more straightforward, but because in includes the "time" aspects as well, then the 2. message won't be true until that time has been reached.
Essentially we want to show the 2. message, as soon as it's the same day (full 24 hours), not match the time as well in order to activate the conditional.