Time difference calculation

Post your questions and help other users.

Moderator: Martin

Post Reply
Specs
Posts: 1
Joined: 16 May 2013 11:23

Time difference calculation

Post by Specs » 16 May 2013 11:28

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!

plm
Posts: 19
Joined: 06 May 2013 22:27

Re: Time difference calculation

Post by plm » 20 May 2013 22:02

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.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Time difference calculation

Post by Martin » 22 May 2013 19:55

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

fiets
Posts: 19
Joined: 23 May 2013 11:06

Re: Time difference calculation

Post by fiets » 26 May 2013 10:25

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.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Time difference calculation

Post by Martin » 27 May 2013 16:52

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

Post Reply