Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to set the curr time on a custom field to curr time of the user's timezone using Behaviour Edited

I need to have Incident End default to now as I close a ticket.  Since I can't use Default value, I'm using a Jira Behaviour instead.

This script works EXCEPT the date/time is off by 12 hours when the timezone is not the same as the default time zone.  If it's 5 PM in the US Central tz and 11 PM in the UK, the UK user closing a ticket has the Incident End set to 11 AM instead of 11 PM.  It works correctly for a user in the US Central tz.  What am I doing wrong?

@BaseScript FieldBehaviours fieldBehaviours

def dateField = getFieldByName("Incident End")

def timeZoneManager = ComponentAccessor.getComponent(TimeZoneManager)
def loggedUserZoneId = timeZoneManager.loggedInUserTimeZone.toZoneId()

DateFormat formatter = new SimpleDateFormat("dd/MMM/yy h:mm a")

def newLocalDateTime =
def newDate = Date.from(newLocalDateTime.atZone(loggedUserZoneId).toInstant())





1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry Community Leader Jan 31, 2020

Hi @Maria DePasquale ,

Not sure if this will solve your issue, but this is the script I am using and it is working fine (it's very similar) : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.timezone.TimeZoneManager

@BaseScript FieldBehaviours fieldBehaviours

def userTimeZone = ComponentAccessor.getComponent(TimeZoneManager).getLoggedInUserTimeZone()
SimpleDateFormat isoFormat = new SimpleDateFormat('dd/MM/yy HH:mm');

def dateField = getFieldByName("Incident End")
dateField.setFormValue(isoFormat.format(new Date()))


Thank you @Antoine Berry  This works!!!

Like Antoine Berry likes this

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you