Skip Navigation

[Resolved] conditional output for time field in date/time custom field

This support ticket is created 5 years, 1 month 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.

Our next available supporter will start replying to tickets in about 1.27 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1213893

I have this conditional output in a view:

[wpv-conditional if="( $(wpcf-date-and-time) ne '' )"]- [types field='date-and-time' style='text' format='g:i a '][/types][/wpv-conditional]

I would like the time field to only show if the time is not 12:00AM (meaning client did not set the time). What do I call time that is 00:00 in the field selector? It displays as 12:00AM but not sure how to call it in this statement.

Thanks!

#1213948

Hi, I think you would have to replace the $(wpcf-date-and-time) syntax to use the types field syntax. This will allow you to test a formatted time, whereas the $(wpcf-date-and-time) syntax would only allow you to test the Unix timestamp. Here's an example:

[wpv-conditional if="( '[types field="date-and-time" style="text" format="g:i a"][/types]' ne '12:00 am' )"]- [types field='date-and-time' style='text' format='g:i a '][/types][/wpv-conditional]
#1215529

That's perfect. Thank you!

#1216991

Great! Let me know if you have trouble implementing this.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.