Get millis since epoch for Jira Automation

David Jose Silva Ruiz March 11, 2021

Hello community,

I'm trying to automatically create annotations in Grafana, and for this, I need to pass an argument in millis (check the documentation here )

I tried this Jira smart value 

{{now.millis}}

But it's returning something that is not the number I'm looking for

now={{now}} > now=2021-03-11T21:00:26.5+0000
milis={{now.millis}} > milis=524000000

Those millis, converted to UTC time is (check here for more details)

Wed Jan 07 1970 01:33:20

 So, is there a way to do this? What does the value returned mean?

2 answers

1 accepted

2 votes
Answer accepted
nmenere
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 15, 2021

Hi Kian,

 

Milliseconds since Epoch was converted over from the old way of formatting dates. 

Good news is the old way is still there:

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

We are tracking adding it to the new way here: https://codebarrel.atlassian.net/browse/AUT-1915

 

Hope that helps,

Nick

David Jose Silva Ruiz March 15, 2021

@nmenere : This is the best answer, and the most simple... but why isn't it anywhere in the documentation? 

Like Kian Stack Mumo Systems likes this
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2021

@nmenere

Thanks for providing this answer! I was searching high and low for a way to do it outside of what I ended up doing. If Atlassian can get it added to the documentation that would be awesome!

nmenere
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 16, 2021

The reason for documentation is that this way of formatting dates is deprecated. The old way is documented at - https://confluence.atlassian.com/automation/archived-date-functions-993924673.html

AldoCauchiSavona November 30, 2022

Thanks a million. Thought it could not be done,  but a friend at work showed me this answer and tested it and it worked :)

1 vote
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 11, 2021

@David Jose Silva Ruiz

I don't know why that isn't working. I found the same behavior when I tried to use that format.

The only way I could eventually get this to work was by making a rest call to a publicly available API to give me the current epoch time and then passing that to another spot in my rule.

Screen Shot 2021-03-11 at 10.39.23 PM.png

 

I  used the endpoint https://showcase.api.linx.twenty57.net/UnixTime/tounix?date=now. That seemed to give me the epoch in seconds, so then to get it to milliseconds I just appended "00" to the end.

Screen Shot 2021-03-11 at 10.42.33 PM.png

David Jose Silva Ruiz March 15, 2021

Thanks @Kian Stack Mumo Systems ! I was working on a similar solution to yours, but querying https://currentmillis.com/time/minutes-since-unix-epoch.php (which returns minutes instead of millis), then I was converting them with this

{{#=}}{{webhookResponse.body}} * 60000{{/}}

I believe both work almost the same, thanks!

Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2021

I was having problems with the formatting when I performed a multiplication. It kept returning a value in scientific notation instead which wasn't helpful!

Italo _Modus Create_ October 1, 2021

Suggest an answer

Log in or Sign up to answer