Jira Timezone javascript

Hi Guys,

I'm trying to implement the javascript for timezones:

Your timezone. The value is set automatically from your browser, so please only modify if it's incorrect. <br>
<b><a href="http://www.worldtimezone.com/" target="timezone">World Timezones</a></b>

<script language="JavaScript">

<!--
function setCustomerTimezone()
{
tzlist = document.getElementById("customfield_13423");
if (tzlist) {
if (/CreateIssueDetails.jspa/.test(tzlist.form.action)) {
// Value has not yet been set if (tzlist.value == -1) {
offset = new Date().getTimezoneOffset() / 60; // hours from GMT
if (offset <= 0) { tzlist.value="GMT+"+(-offset); }
else { tzlist.value = "GMT-"+offset; }
// }
}
}
}

window.onload = setCustomerTimezone;

//-->
</script>

But as stated on the Atlassian guide, it doesn't work beyond 4.3. This seems to be due to the new overlay create issue screen, which "CreateIssueDetails.jspa" obviously doesn't reference.

If I create an issue in the "http://jira-dev.site.com/secure/CreateIssue!default.jspa", this script will work (as was the method you created issues during 4.3.

Does anyone know how to get this working in 6.x? Even if it's a post-function? Atlassian seem to have gotten it working by removing the ability to have an overlay create screen, and effectively going back to a non-overlay method of creating an issue.

Many thanks!

1 answer

Hi Tim,

I tried the following:

Your timezone. The value is set automatically from your browser, so please only modify if it's incorrect. <br>
<b><a href="http://www.worldtimezone.com/" target="timezone">World Timezones</a></b>

<script type="text/javascript">
<!--
jQuery(document).ready(function($) {
setCustomerTimezone();
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { setCustomerTimezone(); });
});


function setCustomerTimezone()
{
tzlist = document.getElementById("customfield_13423");
if (tzlist) {
if (/CreateIssueDetails.jspa/.test(tzlist.form.action)) {
// Value has not yet been set if (tzlist.value == -1) {
offset = new Date().getTimezoneOffset() / 60; // hours from GMT
if (offset <= 0) { tzlist.value="GMT+"+(-offset); }
else { tzlist.value = "GMT-"+offset; }
// }
}
}
}

window.onload = setCustomerTimezone;

//-->
</script>

Doesn't seem to work unfortunately, my javascripting is somewhat.....poop, so I could have gotten it wrong.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,300 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot