Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,737
Community Members
 
Community Events
176
Community Groups

Get millis since epoch for Jira Automation

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 Mar 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

@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

@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 Mar 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

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

@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

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!

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!

Suggest an answer

Log in or Sign up to answer