This thread is resolved. Here is a description of the problem and solution.
Problem:
The user has created a filter on datetime custom field using TODAY() but it does not work well for posts that have a time
Solution:
The user should use the NOW() function or the SECONDS_FROM_NOW(0) function as he is using datetime field.
TODAY() function works well for date fields.
This support ticket is created 3 years, 6 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I'm trying to place a conditional output based on a date + hour. This is used to display the buy button only after a specific date (which is a custom field 'wpcf-date-prevente').
Here is my condiiton :
[wpv-conditional if="( $(wpcf-date-prevente) lte 'TODAY()' )"]
My custom field is a date + hour field. I found an issue when the date is the current date :
- If the hour is 00 00, then it works and the button is displayed.
- If anything else than 00 00 for the hour, then nothing is displayed.
Could you check and tell me if it is possible to use a date / hour field to manage this condition?
Thanks for your answer.
The issue with your proposal is that I need to use the date / time that is stored in the custom field. The aim is to allow the buying of a product after a certian date / hour that is defined thanks to this custom field. For info, this date / time is not the same for all products, so I cannot use your proposal that uses the same delta for all products !
Can you explain how th "TODAY" parameter is managed? Is it only a date or could it be a date / time?
Let's take this example :
Product A has to be in sales on october, 10th at 10AM
Product B has to be in sales on November, 4th at 4PM
So, I have the custom field "date-of-sales" which is a date field and is part of the products. So, I have set the right values for each product.
Now, I have a product template in which I have placed a conditional output on the buy button thanks to this code : [wpv-conditional if="( $(wpcf-date-of-sales) lte 'TODAY()' )"]
If I place the date with an hour equal to 00 00, this is working. If I try with a specific hour (like 10 00 for example), this is not working ! This sounds as if the fact to use the hour in the custom field is breaking something?
But, I think, to still need more details about this. What do you mean by it does not work when using another time than 00 00?
Can activate debug on the shortcode and check the debug info:
The parameter 'SECONDS_FROM_NOW(0) ' is working fine for me. Sorry, I did not see the documentation on this at that page : https://toolset.com/documentation/user-guides/views/date-filters/
I think the NOW() parameter should work fine, anyway, the SECONDS_FROM_NOW(0) fully work for my case.
I also see that the TODAY() parameter is blocked at 00h00m, which explains my issue.
Regards
Pat
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.