Is it possible to convert string into date/time from Jira Automation?

James Duffy May 9, 2023

I'm trying to write an automation that parses a string with a date like

'd/m/yy, h:mmam/pm'

e.g. 5-1-23, 8:00am

Is this possible with Jira automation and the smart values and functions available?

 

Thanks!

1 answer

3 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2023

Hi @James Duffy 

Yes, and you can use the toDate conversion on the field, such as:

{{issue.myField.toDate}}

Try using the jiraDateTime or jqlDateTime formats, as defined in the documentation.  When needed, also convert to your time zone to enforce the desired value.

Kind regards,
Bill

Jennifer Luo July 17, 2023

Hi Bill,

I've tried this and it looks like it only converts the string to a date, without a time. For reference, an example date I am using is 2023-06-15T01:00:30.902Z, and when I use .toDate, it returns 2023-06-22T00:00:00.0+0000

Is there something wrong with my initial string?

Thank you,
Jennifer

Jennifer Luo July 17, 2023

Nevermind, I needed to convert from 2023-06-15T01:00:30.902Z to 2023-06-15T01:00:30.902+0000, and then it worked with no issues.

Like # people like this
Pragya Gurung November 1, 2023

Hi, I'm facing the same issue now with .toDate ignoring time. How did you convert 2023-06-15T01:00:30.902Z to 2023-06-15T01:00:30.902+0000? Did you do this inside the automation rule?

Jennifer Luo November 2, 2023

i stored the value in a variable, e.g. time = 2023-06-15T01:00:30.902Z

then did the following:

{{time.replace("Z","+0000").toDate}}

Like # people like this
Jennifer Luo November 2, 2023

an alternative is to also just do variable time = 2023-06-15T01:00:30.902Z

then:

{{time.toDate("YYYY-MM-dd'T'hh:mm:ss.SSS'Z'")}} or whatever format your time string is currently

Like Pragya Gurung likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events