Skip Navigation

[Résolu] Conditional Output Comparing Two Custom Date Fields

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Conditional Output Comparing Two Custom Date Fields

Solution:
post date field value stored as date string and custom date field value stored as timestamp - so to convert it we need to convert the date string to the timestamp and later you can compare the values.

You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/conditional-output-comparing-two-custom-date-fields/#post-1112708

Relevant Documentation:

This support ticket is created Il y a 6 années et 2 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Marqué : 

Ce sujet contient 3 réponses, a 3 voix.

Dernière mise à jour par troyR-2 Il y a 6 années et 2 mois.

Assisté par: Minesh.

Auteur
Publications
#1112339

I have two post types (A and B) that are related via a one to many relationship. I have a View with a post edit link shortcode to edit the 'child' post (B) in a CT. The CT contains fields from the 'child' post (B) and I would like content displayed if a date field in Post A is older (earlier) than a date field in Post B.

I've tried this two ways but the content is displayed whether Post A date field is older than Post B date field or not.

here's what I've tried:-

[wpv-conditional if="( $(wpcf-post-a-date item='@a-b.parent') lte $(wpcf-post-b-date)"]Caution!![/wpv-conditional]
[wpv-conditional if="( [types field='post-a-date' item='@a-b.parent'][/types] ne [types field='post-b-date'][/types]"]Caution!![/wpv-conditional]

[types field='post-a-date' item='@a-b.parent'][/types] on its own displays the date from Post A so I know the relationship is OK.

Can you point me in the right direction please?

Thanks

#1112708

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - as far as I can see you are comparing the post date field with custom date field - is that correct? If yes:

If yes - post date field value stored as date string and custom date field value stored as timestamp - so to convert it we need to convert the date string to the timestamp.

#1113429

All sorted now - thank you!

#1155621

Again the answer is not complete. Don't just make a statement. Add the example.