Jira helpfully converts all date-time fields to the user's local Timezone. However, there are cases where this is undesirable. We need to track an 'Event time' that must always be in UTC, regardless of who is viewing it and their local TZ.
AFAIK, there is no way to achieve this without creating a new field type. Has anyone solved this problem? If so, how? We user scriptrunner extensively so pointers on how to achieve this, or to buy a plugin that already has it, are most welcome.
Hi @Chris Melville , see if this helps you
1: Identify the Original Date/Time Field
Make sure you already have a custom field of type Date/Time that will be used as the source for the calculation.
Locate the ID of the field
Step 2: Create a Scripted Field
Go to ScriptRunner → Scripted Fields.
Click Create Script Field.
Configure the field:
Name: Event Time (UTC)
Template: Date/Time (important to match the script's return type).
Description: "Displays the event time in UTC, based on the original field."
3: Add the Script
Copy the following script into the Script section:
import com.atlassian.jira.component.ComponentAccessor
import java.time.ZonedDateTime
import java.time.ZoneOffset
import java.util.Date
// ID of the original Date/Time field
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dateTimeField = customFieldManager.getCustomFieldObject("customfield_XXXXX") // Replace with your field ID
if (dateTimeField) {
def fieldValue = issue.getCustomFieldValue(dateTimeField) as Date
if (fieldValue) {
// Convert the value to UTC and return as Date
def utcDate = ZonedDateTime.ofInstant(fieldValue.toInstant(), ZoneOffset.UTC)
return Date.from(utcDate.toInstant())
}
}
return null
Replacecustomfield_XXXXX
with the actual ID of your source Date/Time field.
4: Add the Scripted Field to Screens
5: Test the Configuration
Create or edit an issue that uses the original Date/Time field (customfield_22218
).
Verify that the Scripted Field (Event Time (UTC)
) displays the correct time converted to UTC.
Additional Notes
Read-Only Field: Scripted Fields are calculated dynamically and cannot be edited directly. The value depends entirely on the source field (customfield_XXXXX
).
Field Visibility: Ensure the source Date/Time field is added to the screens where users can populate it, as the Scripted Field depends on its value.
def utcDate = ZonedDateTime.ofInstant(fieldValue.toInstant(), ZoneOffset.UTC)
can be modified to convert the date to other time zones instead of UTC. Hello @Chris Melville
Date/time fields are stored as UTC in the Jira database. They are converted for display based on the viewing user's timezones setting.
Can you tell us more about the problem you are trying to solve? Is the problem related to displaying the data in UTC? Why would you need to do this? Do you need to filter data by UTC? Do you need to report based on UTC?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The usage is to track an 'Event Time' which must always be shown in UTC so that it can be used to index into external data sets, graphs, etc. The data might be entered or viewed in one of many different timezones, but must always remain unaltered regardless of the use.
We just need a date-time picker that does no TZ conversion at all. The help text for the field would indicate the field is always considered to be a UTC time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not aware of any method to "lock" a native Jira date/time/timestamp field to take the entry as UTC and display only UTC regardless of a user's timezone preference. I have not found anything in Atlassian's public backlog for that either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.