Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Best way of testing if datestamp in field is '3 months old' in autoaction?

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 4 months ago - 8 years 3 months ago #283138 by fribse2011
Hi Guys

I have a function where I put a datestamp in a field.
I need to check if that is then three months old.
So I will create an autoaction that triggers on 'Users'.

But what is the smartest way of checking if the date is three months old?

For now the datestamp is done with this:
[cb:parse function="time"][cb:date format="Y-m-d" /][/cb:parse]
As this is not in use yet, it can be changed if it's not the best way of doing it?

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: 8 years 3 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 4 months ago #283168 by krileon
The time function in short is just running the supplied string through strtotime. The optional time parameter is strtotime with the string set as now with the time being the time parameter. See the below for strtotime documentation.

php.net/manual/en/function.strtotime.php

How you use it is entirely up to you, but the easiest is to just output what month it is and check if it's greater than or equal to 3. Examples as follows.

[cb:date format="m" /] Greater Than or Equal To 3

[cb:parse function="date" date-format="m" time-format=""]2015-01-13 16:22:43[/cb:parse] Greater Than or Equal To 3


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.

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

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 4 months ago #283189 by fribse2011
Hi Kyle

Hmm, how does that tell me if the datestamp is three months old?
Doesn't that just tell me if it's in one of the first three months?

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: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 4 months ago - 8 years 4 months ago #283229 by krileon
It means it's March or later. I guess it doesn't but you didn't provide what it's supposed to be comparing to. 3 months older than what? Do you mean is today 3 months older than the date? That would be an entirely different comparison.


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: 8 years 4 months ago by krileon.

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

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 4 months ago #283254 by fribse2011
Not entirely true. But I'll try and explain more.clearly.
I have a field, in that field I'm going to place a timestamp of today.
I then need to make a function that triggers if that stamp is three months old.
So three months after the field is set, something happens.

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: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 4 months ago #283271 by krileon
Ok, to do that you need to take that timestamp, add 3 months, then see if it's less than or equal to current timestamp. The below should do this.

[cb:parse function="time" time="+3 MONTHS"][cb_timestamp][/cb:parse] Less Than or Equal To [cb:parse function="time"][cb:date format="Y-m-d" /][/cb:parse]

Change Y-m-d to Y-m-d H:i:s if you need time exact time as well.


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.

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

Moderators: beatnantkrileon
Powered by Kunena Forum