Page 1 of 1
Current time in a flow?
Posted: 05 Mar 2013 15:43
by giovag7
Hi all
I would know how to obtain current time in a flow. The only i have found is triggertime, but i need actual time in a my flow.
Thank you.
Re: Current time in a flow?
Posted: 05 Mar 2013 19:59
by inReinbek
Re: Current time in a flow?
Posted: 06 Mar 2013 07:24
by Martin
You can use the function getDate() to fetch the current system time when the function is invoked.
In a script something like this:
now = getDate();
or inline in a text field that supports variables (for example action Notification on Screen):
{getDate()}
or formatted:
{getDate(),dateformat,HH:mm:ss}
Re: Current time in a flow?
Posted: 06 Mar 2013 09:24
by giovag7
Martin wrote:You can use the function getDate() to fetch the current system time when the function is invoked.
In a script something like this:
now = getDate();
or inline in a text field that supports variables (for example action Notification on Screen):
{getDate()}
or formatted:
{getDate(),dateformat,HH:mm:ss}
Thank you!
I will try as soon as possible.
Re: Current time in a flow?
Posted: 06 Mar 2013 13:58
by giovag7
Martin wrote:You can use the function getDate() to fetch the current system time when the function is invoked.
In a script something like this:
now = getDate();
or inline in a text field that supports variables (for example action Notification on Screen):
{getDate()}
or formatted:
{getDate(),dateformat,HH:mm:ss}
Hi Martin
this work well.
I have another need but i can't figure out on how to do this:
i would do a calculation between two times (in HH:mm). I mean the difference between two times, example:
triggertime 08:40, current time 13:10: can i obtain the difference (in this example 04HH:30mm)?
Thank you
Re: Current time in a flow?
Posted: 08 Mar 2013 13:42
by Martin
triggertime is a number containing the milliseconds since 1970. getDate() also returns milliseconds since 1970.
You can calculate the difference to get the duration in millis (in an action Script):
diff = getDate() - triggertime;
and formatted to the duration format often used in Automagic:
formatted = getDurationString(diff);//for example 5s 30ms
or combined:
formatted = getDurationString(getDate() - triggertime);