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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you