The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
not sure how to use 'time_ago' short code
Hi,
I've never used this shortcode before and could use help in explaining if i'm doing it correctly.
I am trying to calculate a 'rate' i.e. unit of change over time (say two units of time / 10 days = 0.2)
My understanding is the the short code 'time_ago' works with a date field. So if I have a user enter the value of their 'start date', which say is July20, 2017, and todays' date is July 30, 2017, i should have a 'time_ago' value of 10 days (30th - 20th)?
The short code i used is [123 time_ago=1]; 123 is the field id of my date field. This calculation is stored in field id = 456.
a) is the above correct use of 'time_ago'?
b) will this 'time_ago=1' default to the largest units of time? In my case, days; but what if it were 500 days? would the returned value be '1' (year).. and whatever decimal places i choose? Since i can't get this to work, I can't even determine if it's even supposed to return numerals only or the 'word' also i.e. 'days' or 'years'. Hope that made sense.
c) does it calculate the time_ago value, retroactively with ALL my entries in that form?
So my final calculation of rate of change, (calculated within my form within a 'number field'), would look something like, my unit of time, say field id=1, value of '2' (same as mentioned above), would look like... [1]/[456]. Is this the right idea to calculate rate of change?
July 29, 2017 at 5:44 am
According to this support thread, the time_ago shortcode only works in views, not as a dynamic value in a form. https://formidableforms.com/help-desk/x-time_ago1-does-not-seem-to-be-working/
It's not clear from your post, but it sounds like you are using it to perform date math on a form. If that's the case, you have to write your own code.
July 29, 2017 at 1:58 pm
Thanks Victor for your reply.
Well, correct. More accurately, I'm trying to generate graphs based on math. And apparently any math calculations must be performed within the form that will eventually be drawn upon to create the graph.
To perform this math, one apparently has to create a 'number' field within your form and perform a 'dynamic value calculation'. Clicking on the 'calculate the default value' check box opens a field that allows one to enter an calculation expression. This was my understanding from support at least, unless I misinterpreted it. Regardless, if 'time_ago' short code is only meant for views, than perhaps this is why it isn't appearing to operate as expected.
I'm a bit confused now if i use 'time_ago' to calculate a number to display in a view, how exactly am i going to create a graph from that? lol. I feel like i'm going in circles. Sooo not easy, as I would think it should be. :)
July 31, 2017 at 5:05 am
Date math is always difficult. You can't use the time_ago shortcode to create a graph. You need to follow the instruction support provided. You have to perform the calculations at the form level when the form is being created. Create hidden fields on your form to capture the calculation results. Display these hidden fields on your graph.
Discussion closed.