Skip Navigation

[Resolved] conditional display comparing dates with today

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by fabriceS 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1927693

My CPT have a field of availability which is a date.

when I display that date, I'd like to create a conditional display and display the date if it is in the future, but if the availability date is today or before, I'd like to display a kind of "available now".

How can I compare the dates ?

Thanks for your help.

#1927965

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can use the TODAY() function to compare your custom date field.

For example:

[wpv-conditional if="( '[types field='date-field' output='raw'][/types]' lte 'TODAY()' )"]
available now
[/wpv-conditional]
[wpv-conditional if="( '[types field='date-field' output='raw'][/types]' gte 'TODAY()' )"]
Display your date field
[/wpv-conditional]

Please check the following:
https://toolset.com/documentation/legacy-features/views-plugin/debugging-views-output/

#1935501

My issue is resolved now. Thank you!