Date time addition and subraction
Posted: 04 Dec 2016 19:02
Unless I miss something very simple, I can't seem to find functions to do addition and subtraction on datetime ...
How do I get a time difference?
global_var1="{getDate(),dateformat,HH:mm:ss}";
global_var2="{getDate(),dateformat,HH:mm:ss}";
timedifference="{global_var2-global_var1,dateformat,HH:mm:ss}";
The above script does not work.
For example, I have a datetime1 of "13:22:10" and a datetime2 of "13:23:30". I want to do the subtraction between datetime2 and datetime1, and I expect to get the result of "1m 20s".
I read somewhere and something about converting datetimes to milliseconds since 1970, doing subtraction on milliseconds, and then convert the milliseconds back to datetime format ... is this the way to do it? if so, how? How to do addition and subtraction on datetimes and get the result back in {datetime, pattern} format or duration string format??
How do I get a time difference?
global_var1="{getDate(),dateformat,HH:mm:ss}";
global_var2="{getDate(),dateformat,HH:mm:ss}";
timedifference="{global_var2-global_var1,dateformat,HH:mm:ss}";
The above script does not work.
For example, I have a datetime1 of "13:22:10" and a datetime2 of "13:23:30". I want to do the subtraction between datetime2 and datetime1, and I expect to get the result of "1m 20s".
I read somewhere and something about converting datetimes to milliseconds since 1970, doing subtraction on milliseconds, and then convert the milliseconds back to datetime format ... is this the way to do it? if so, how? How to do addition and subtraction on datetimes and get the result back in {datetime, pattern} format or duration string format??