This article is meant to help projects where it is necessary to change the date & time format from a Jira field or Form field.
At the moment the Forms date format is not the same as Jira date format as the Forms date format will be always "dd/MM/yyyy" or "MM/dd/yyyy" and not other formats. We have a bug ticket that was created for this topic:
Also, note that the Forms works exactly with the same time zone that was chosen in the "Account preferences" of the user, as you can see on the screen recording below:
Therefore, as a workaround in order to automatically change the format or recalculate a specific time zone, it will be needed to use an automation rule with smart values in a custom text field.
Create a new custom Date Jira field and Text field:
Select > Issues.
Under FIELDS, select Custom fields.
Click Create custom field. Make sure to select All to view the available field options.
Select the type of field to the Text field and click Next. See a list and descriptions for the available custom field types in company-managed projects.
Add the details for your field.
The name you select appears as the custom field's title wherever the field appears. The description appears below the field when creating and editing issues, but not when browsing issues.
When you have entered the field details, select Create.
Add the new custom field to one or multiple screens by ticking the corresponding box and click Update.
To link a form field to a Jira field. It will require linking all form fields to custom Jira fields (this is necessary for the A4J to be able to get the answers from the fields):
From the navigation on the left, select Project settings or Service project settings > Forms.
Find the form you want to edit, and select More (...) > Edit.
Find and select the field you want to link to a Jira field.
In the right-hand panel, under Linked Jira field, select the Jira field you want to populate with the information in your form field:
Select Save changes.
Note: To link form fields with Jira fields, certain criteria must be satisfied, or your form may not work as expected, please refer to Link a form field to a Jira field for
more information.
And it will be necessary to leave the form open on issue creation (it is important for having communication between Jira Forms and the A4J):
So the icing on the cake for automatically changing the date format and recalculating the time zone is by using the smart value below:
UK Format:
{{issue.customfield_xxxx.convertToTimeZone("Europe/London").format("dd/MM/yyyy hh:mm:ss")}}
US Format:
{{issue.customfield_xxxx.convertToTimeZone("America/Chicago").format("MM/dd/yyyy hh:mm:ss")}}
The full list of formats are below:
Format |
Thursday, November 1, 1979 6:23:12 AM UTC |
---|---|
Default (none specified) |
1979-11-01T11:23:12.0+0000 |
jiraDate |
1979-11-01 |
jiraDateTime |
1979-11-01T06:23:12.0-0500 |
jqlDate |
1979-11-01 |
jqlDateTime |
1979-11-01 06:23 |
shortDate |
11/1/79 |
shortTime |
6:23 AM |
shortDateTime |
11/1/79 6:23 AM |
mediumDate |
Nov 1, 1979 |
mediumTime |
6:23:12 AM |
mediumDateTime |
Nov 1, 1979 6:23:12 AM |
longDate |
November 1, 1979 |
longTime |
6:23:12 AM EST |
longDateTime |
November 1, 1979 6:23:12 AM EST |
fullDate |
Thursday, November 1, 1979 |
fullTime |
6:23:12 AM EST |
fullDateTime |
Thursday, November 1, 1979 6:23:12 AM EST |
format("<pattern>") e.g. format("dd/MM/yyyy") Refer to the Java documentation for pattern syntax. |
01/11/1979 |
This workaround will work as shown in the screen recording below (note that it will be always essential to refresh the page to give A4J enough time to execute the automation rule and the attached form must be open for the date form field to be updated):
Bruno Altenhofen
Atlassian Engineer - The guy from Proforma(Jira Forms)
e-Core
Krakow - Poland
1 accepted answer
4 comments