Current time in a flow?

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
giovag7
Posts: 58
Joined: 05 Mar 2013 10:02

Current time in a flow?

Post by giovag7 » 05 Mar 2013 15:43

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.

inReinbek
Posts: 95
Joined: 02 Feb 2013 22:04

Re: Current time in a flow?

Post by inReinbek » 05 Mar 2013 19:59


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

Re: Current time in a flow?

Post by Martin » 06 Mar 2013 07:24

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}

User avatar
giovag7
Posts: 58
Joined: 05 Mar 2013 10:02

Re: Current time in a flow?

Post by giovag7 » 06 Mar 2013 09:24

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.

User avatar
giovag7
Posts: 58
Joined: 05 Mar 2013 10:02

Re: Current time in a flow?

Post by giovag7 » 06 Mar 2013 13:58

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

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

Re: Current time in a flow?

Post by Martin » 08 Mar 2013 13:42

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);

Post Reply