Skip Navigation

[Resolved] Conditional outpur with date

This thread is resolved. Here is a description of the problem and solution.

Problem:
Display the content on condition Today's date is 2 days after the end of subscription date field
Solution:
Use wpv-conditional shortcode like this:
[wpv-conditional if="( $(wpcf-end-of-subscription) lt ('TODAY()' - 24 * 60 * 60 * 2) )"]Hello, I'm 2 days after the end of subcription[/wpv-conditional]
Relevant Documentation:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional

This support ticket is created 8 years, 2 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Pat 8 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#368864

Pat

Hello,
I have a custom field 'end-date' and I want to display a part of the Views only when we have reach this end-date + 2 days.
I have currently a code which is working for end-date = today :
[wpv-conditional if="( $(wpcf-end-date) gte 'TODAY()' )"]
How can I extend this in order to cope with TODAY + 2 days?

Thanks
Pat

#369038

Dear Pat,

Please try this:

[wpv-conditional if="( $(wpcf-end-date) gte ('TODAY()' + 24 * 60 * 60 * 2) )"]
asdasd
[/wpv-conditional]
#369112

Pat

Hi Luoy,
Thanks for your feedback.

I'm wondering if I did not make a mistake as it seems that lt would fit better than gte for this case.
(I want the content to be visible 2 days after the end-date) ?
Second point, even with this, I have tried your solution and nothing is displayed (even if I'm changing the end-date). Here is my code :

[wpv-conditional if="( $(wpcf-end-date) lt ('TODAY()' + 24 * 60 * 60 * 2)"][wpv-view name="Engagements concours"][/wpv-conditional]

Any idea?
Regards
Pat

#369471

I assume you are going display the content only when:
1) wpcf-end-date is greater than today
2) wpcf-end-date is less than 2 future days

Please try this:

[wpv-conditional if="( $(wpcf-end-date) lt ('TODAY()' + 24 * 60 * 60 * 2) ) AND ( $(wpcf-end-date) gt ('TODAY()') )"]
I want the content to be visible 2 days after the end-date
[/wpv-conditional]

See the live test website:
hidden link
user/pass: xgren/111111

#369506

Pat

Hi Luoy,
Sorry, I have not been clear.
I want to display the cconditional content only after end-date + 2 days.

So here is my code :
[wpv-conditional if="( $(wpcf-concours-date-limite-inscription) lt ('TODAY()' + 24 * 60 * 60 * 2)"][wpv-view name="Engagements concours"][/wpv-conditional]

I made several test using different end-date and the conditional view is displayed for :
end-date >= today
Ex : taking the current today's date (Feb, 23rd), if I place Feb, 22nd as end-date, nothing is displayed. If I place Feb, 23rd as end-date, then the display is OK !

Any idea?
Regards
Pat

#369540

Sorry, I still do not clear the question:
1) I want to display the cconditional content only after end-date + 2 days.
What date do you want to compare?
in your codes:
$(wpcf-concours-date-limite-inscription) lt ('TODAY()' + 24 * 60 * 60 * 2)
It means the custom date field value "concours-date-limite-inscription" is less than today's date + 2 days

2) And I tested it in above test site:
hidden link
setup as end-date as February 22, 2016
and using same codes as you mentioned above:
[wpv-conditional if="( $(wpcf-end-date) lt ('TODAY()' + 24 * 60 * 60 * 2) )" debug="true"]
I want the content to be visible 2 days after the end-date
[/wpv-conditional]
It does output the string:
I want the content to be visible 2 days after the end-date
Could you duplicate same problem in above test site? thanks

#369561

Pat

Hi Luoy,
I have created a new postyoe in yoru site (concours) and a content view integrated the code :
[wpv-conditional if="( $(wpcf-end-of-subscription) lt ('TODAY()' + 24 * 60 * 60 * 2) )"]Hello, I'm 2 days after the end of subcription[/wpv-conditional]

If I put current date as end-of-subcription date, then, the output is displayed !

Could you have a look on it please
Thanks
Pat

#370011

It seems there is a logic error in your codes, if you need display the content depends on:
Today's date is 2 days after the end of subscription, please try this:
[wpv-conditional if="( $(wpcf-end-of-subscription) lt ('TODAY()' - 24 * 60 * 60 * 2) )"]Hello, I'm 2 days after the end of subcription[/wpv-conditional]

If you need to display the content depends on:
the end of subscription is before the day after tomorrow, you can try this:
[wpv-conditional if="( $(wpcf-end-of-subscription) lt ('TODAY()' + 24 * 60 * 60 * 2) )"]Hello, the end of subcription is before the day after tomorrow[/wpv-conditional]

#370022

Pat

Hi Luoy
Many thanks for your support.
That's OK now and I should have though about this before !!!
Regards
Pat

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