difference between schedules

peppe10

Member
Hello to all, in a form I created two time fields and a field field (elapsed time). Is it possible to know automatically the elapsed time? Thank you all
 
Do you take this approach to every thing you do? Starting a project without bothering to do any learning beforehand, and then as soon as you run into the first difficulty you don't go and look for an answer in e.g. the wiki, but instead expect other people to do it for you?

Go an research this yourself. And if in a week you still haven't found out how to do it, come back and I will give you a pointer.
 
@Sophist That's ... harsh. These forums are for people to ask for help. If you don't want to help, that's fine, but there's no need to insult people.

@peppe10 - easiest way is probably to make the 'elapsed' element a calc, and enable AJAX on it. The time element data is in the form "h:m:s", so the difference would be something like this, if your two time elements are called time1 and time2.

Code:
// get the time1 value, 'explode' it into an array, and calculate the total seconds
$time1_raw = '{yourtable___time1_raw}';
$time1 = explode(':', $time1_raw);
$seconds1 = ($time1[0] * 60 * 60) + ($time1[1] * 60) + ($time1[2]);

// do the same for time2
$time2_raw = '{yourtable___time2_raw}';
$time2 = explode(':', $time2_raw);
$seconds2 = ($time2[0] * 60 * 60) + ($time2[1] * 60) + ($time2[2]);

// return the difference
return $seconds2 - $seconds1;

I happen to have a calc that does something similar, so I was able to copy and paste most of this (mine just renders the total seconds for one time element in a calc).

If you'd like to add this to the wiki for the time element as another example, that'd be cool:

http://fabrikar.com/forums/index.php?wiki/time-element/

-- hugh
 
Thanks for the code example earlier in this tread. I have used this code only modifying the elements with my element names for time1 and time 2.

The code seems to be working for the hours, but when I change the minute value for either there is no change in the results. Both are working just fine when making changes to the hours value. I do not see any reason why $time1[1] or $time2[1] does not contain the value set for minutes.

Being that everything is straight forward not sure what could the issue be.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top