Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Unix date/time in automation

Terry Dance
Contributor
October 30, 2024

I need to call an API and it uses millis for its date range based on Unix.

What I want to date is call the API now to get data, then pull data for the same time range but 1 week ago.

What I am just struggling to do is automate the system to get the "now" time in milliseconds.

Has anyone got any ideas?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
3 votes
Answer accepted
Tim Kopperud
Community Champion
October 30, 2024

Hi @Terry Dance, you might try something like this:

{{#now}}toMillis{{/}}

An example rule with this entry:

 image.png

Will result in this Audit log entry:

image.png

TimK

Terry Dance
Contributor
October 30, 2024

Yeah that worked perfectly.

Thanks!

Like Tim Kopperud likes this
Tim Kopperud
Community Champion
October 30, 2024

Great. Thanks for accepting the answer.

TimK

Terry Dance
Contributor
October 30, 2024

I've then tried to take away 60 minutes from the time your answer gives using

{{#=}}{{starttime}} - 3600000{{/}}

but it spits out "1.730282217675E12"

Any ideas on that?

It does record the start time correct as "1730285817675"

Tim Kopperud
Community Champion
October 30, 2024

@Terry Dance, this wasn't easy to solve. Let us try another approach. Please try this:

{{now.withYear(1970).withDayOfYear(1).withHour(0).withMinute(0).withSecond(0).withMillis(0).diff(now).millis.minus(3600000)}}

Messy, I know. But it seems to work per your requirements as I understand.

image.png

image.png

I don't know why ".millis" doesn't works as wanted directly with "now". 

TimK

TAGS
AUG Leaders

Atlassian Community Events