How to change a form date field format and convert the time zone

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.

Workaround steps:

Create a new custom Date Jira field and Text field:

  1. Select > Issues.

  2. Under FIELDS, select Custom fields.

  3. Click Create custom field. Make sure to select All to view the available field options.

  4. 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.

  5. 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.

  6. When you have entered the field details, select Create.

  7. 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):

  1. From the navigation on the left, select Project settings or Service project settings > Forms.

  2. Find the form you want to edit, and select More (...) > Edit.

  3. Find and select the field you want to link to a Jira field.

  4. In the right-hand panel, under Linked Jira field, select the Jira field you want to populate with the information in your form field:
    Screenshot 2023-08-21 at 18.09.59.png

  5. 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):

  • Screenshot 2023-08-21 at 18.26.09.png

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")}}
  • Screenshot 2023-08-21 at 18.41.34.png

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):

4 comments

Tomislav Tobijas
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.
August 21, 2023

Cool. Not sure that I'll need to format dates in the near future but I didn't know that updating the Jira field will also update the form field if the form is left open. Good to know :)

I'm curious - what if there are multiple (same) forms attached and they are all open? Will they all be updated accordingly?
I actually never had a case where I had more than one form attached so I'm not sure if that's even possible 😅

Like Bruno Altenhofen likes this
Rick Westbrock August 28, 2023

I appreciate this detailed workaround. It is especially helpful since I see that the bug transitioned into Short Term Backlog 15 months ago but apparently no work has started yet (I guess Atlassian's idea of "short term" is different than mine).

Like Bruno Altenhofen likes this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2023

Hi @Tomislav Tobijas

Thanks for the feedback!

I'm curious - what if there are multiple (same) forms attached and they are all open? Will they all be updated accordingly?

Allow me to share with you that the desired scenario will be possible using the new Jira Forms API, where you will be able to manipulate the forms separately. For more information please refer to the article below:

Thanks!

Like Tomislav Tobijas likes this
Tomislav Tobijas
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.
September 20, 2023

@Bruno Altenhofenbrilliant! Thanks for sharing! 🙌

Like Bruno Altenhofen likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events