Hour of day when issue was created


This script allows you to easily calculate how many hours after the start of a working day an issue was created.


I have an SLA with my clients which we need to adhere to, part of this SLA is knowing how many hours an issue was created after the start of the working day. However, Jira is not configured to provide this information, so this script has helped me with my reporting and time keeping.

Good to Know

  • This script considers the users time zone.


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.timezone.TimeZoneManager import java.time.ZonedDateTime import static java.time.temporal.ChronoUnit.HOURS final issueKey = "ABC-1" //Replace with the issue key TimeZoneManager tzm = ComponentAccessor.getComponent(TimeZoneManager) IssueManager issueManager = ComponentAccessor.issueManager def issue = issueManager.getIssueObject(issueKey) ZonedDateTime creationTime = ZonedDateTime.ofInstant(issue.created.toInstant(), tzm.loggedInUserTimeZone.toZoneId()) ZonedDateTime startOfDay = creationTime.toLocalDate().atStartOfDay(creationTime.zone) HOURS.between(startOfDay, creationTime)
Discovered an issue? Report it here

Suggested for you