Skip to Content Skip to Menu

🕒 Save Time and Effort with CB Editor Assistant: Effortlessly create and refine content in Joomla 3, 4, & 5.
🎁 Limited Offer: Enjoy a 5-day FREE trial and save up to 30% afterward!

[SOLVED] One more syntax that I can't get my head around in Auto Actions

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
7 years 11 months ago - 7 years 11 months ago #291104 by fribse2011
So I want to check if a user is turning 18 this year, it will be run 31/10 of each year.
I've built this condition:
[cb:parse function="date" date-format="Y" date="+18 years" time="false"][cb_birthday][/cb:parse]] EQUAL TO [cb:parse function="date" time="false"][cb:date format="Y"/][/cb:parse]
The debugger gives me:
Condition 2 failed for 387: 2007 Lig med 01.01.1970
So the date function gives me 1970?

I also tried with
[cb:parse function="date" date-format="Y" date="+18 years" time="false"][cb_birthday][/cb:parse]] EQUAL TO [cb:parse function="time"][cb:date format="Y" /][/cb:parse]
But the time function returns ticks, and not the year :-)

I also tried
[cb:parse function="time" date-format="Y" time="+18 years"][cb_birthday][/cb:parse] equal to [cb:parse function="time"][cb:date format="Y" /][/cb:parse]
And that got me a a bit closer, the debug gives me

Condition 2 failed for 391: 1519862400 Equal to 1486412220
Condition 2 failed for 392: 1488326400 Equal to 1486412220

The first is 17 years old, the latter will be 18 on march 1st, but it doesn't hit it either.

So how do I get it exactly right?

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Last edit: 7 years 11 months ago by fribse2011.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 11 months ago - 7 years 11 months ago #291133 by krileon
You don't need the date parser around the cb:date usage. It already formats it correctly. So in your case the below should compare their birthday +18 years against the current year.

[cb:parse function="date" date-format="Y" date="+18 YEARS" time="false"][cb_birthday][/cb:parse] EQUAL TO [cb:date format="Y" /]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 7 years 11 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
7 years 11 months ago #291162 by fribse2011
Ok, I overdid it then :-)

Now I get a different result for the first compare?

It doesn't add the 18 years to the date???
[cb:parse function="date" date-format="Y" date="+18 years" time="false"][cb_birthday][/cb:parse] Equal to [cb:date format="Y" /]
The user that is registered as being born in 1999 shows this in the debug:

Condition 2 failed for 392: 1999 Equal to 2017

So for some reason it doesn't add the 18 years?

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 11 months ago #291171 by krileon
Whoops that's the wrong parser function. That function just formats a date. It can't modify it. You're trying to do a strtotime operation, which means you need to use the time function. Below should work.

[cb:parse function="date" date-format="Y" time="false"][cb:parse function="time" time="+18 YEARS"][cb_birthday][/cb:parse][/cb:parse] Equal To [cb:date format="Y" /]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: fribse2011

Please Log in or Create an account to join the conversation.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
7 years 11 months ago #291184 by fribse2011
Darned, that is cool, so a double parse.
Thankyou, it works as I hoped!

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum