Hi,
Want to calculate the time difference between triggertime and a previous triggertime that is saved to a global variable.
I see that triggertime does contain a timestamp but also other "readable" date and time info.
If I can just extract the timestamp alone I assume I could just subtract the two and have the millisecond difference.
How do I get the timestamp from the triggertime variable?
Thanks!
Time difference calculation
Moderator: Martin
Re: Time difference calculation
I'm not sure it can worthwhile ...
var_timestamp = {triggertime, dateformat, HH:mm:ss}
var_timestamp is equal to, for example, "22:05:38"
Best.
var_timestamp = {triggertime, dateformat, HH:mm:ss}
var_timestamp is equal to, for example, "22:05:38"
Best.
Re: Time difference calculation
Hi,
The variables with a date/time like triggertime internally contain the milliseconds since 1970. You can directly calculate the difference of such variables in a script:
global_time1 = getDate();
sleep(100);
time2 = getDate();
diff_in_millis = time2 - global_time1;//calculate the difference in milliseconds
formatted_diff=getDurationString(diff);//format to a string like "102ms"
log(formatted_diff);
Regards,
Martin
The variables with a date/time like triggertime internally contain the milliseconds since 1970. You can directly calculate the difference of such variables in a script:
global_time1 = getDate();
sleep(100);
time2 = getDate();
diff_in_millis = time2 - global_time1;//calculate the difference in milliseconds
formatted_diff=getDurationString(diff);//format to a string like "102ms"
log(formatted_diff);
Regards,
Martin
Re: Time difference calculation
Hi,
Does this calculation also works through different flows.
I mean flow 1 is date/time x, flow 2 is date/time y, and flow 2 calculates the difference between x and y?
Thanks in advance.
Does this calculation also works through different flows.
I mean flow 1 is date/time x, flow 2 is date/time y, and flow 2 calculates the difference between x and y?
Thanks in advance.
Re: Time difference calculation
Hi,
Yes, but the variables have to be global to be visible in another flow:
Flow 1:
global_x=getDate();
Flow 2:
y = getDate();
diff = global_x - y;
Regards,
Martin
Yes, but the variables have to be global to be visible in another flow:
Flow 1:
global_x=getDate();
Flow 2:
y = getDate();
diff = global_x - y;
Regards,
Martin