ConvertToTimeZone not working
Asked by Esteban Borja Lopez:

Hello community,

I have a simple automation rule that set OLA/SLA target times based on creation date-time of a given ticket.

As I want to setup different timezones depending on the project/customer location (so timer is set on local time), and understanding that ticket creator personal settings are being taken to define the timezone, I want to make sure that the times are always converted to the expected timezone for that given project (e.g. Europe/Madrid).

To do so, im using the following expression to edit a custom field:

* **{{issue.Created.convertToTimeZone("Europe/Madrid").plusMinutes(15)}}**

The expectation is that irrespective of the timezone setting of the ticket creator (even if not defined, it will take default system value), the creation date is always converted to the timezone I define, but this is not working properly. Here some real examples:

* This rule takes the creation date and convert it to Bolivia time (using canonical id [as indicated in documentation](http://joda-time.sourceforge.net/timezones.html)), and add the defined time (15mins and 4hours for Response Time and Resolution Time respectively):
  * Rule Config:
    * ![Screenshot 2022-05-12 at 11.40.59.png](https://community.atlassian.com/t5/image/serverpage/image-id/197021i37FD593F30A79FDB/image-size/large?v=v2&px=999 "Screenshot 2022-05-12 at 11.40.59.png")
  * Creation date timestamp for a random ticket chosen:
    * ![Screenshot 2022-05-12 at 11.50.42.png](https://community.atlassian.com/t5/image/serverpage/image-id/197022i8410D7A34111D766/image-size/large?v=v2&px=999 "Screenshot 2022-05-12 at 11.50.42.png")
* The expected results for automation are:
  * **OLA Response Time Target** = **May 12, 2022, 5:32 AM** ----\> Bolivia timezone (-6 hours from my time) + 15 mins

  * **OLA Resolution Time Target** : **May 12, 2022, 9:17 AM** ----\> Bolivia timezone (-6 hours from my time) + 4 hours

* Actual results are:
  * **OLA Response Time Target** = **May 12, 2022, 11:32 AM** ----\> Madrid timezone (the same timezone defined on my profile) + 15 mins

  * **OLA Resolution Time Target** : **May 12, 2022, 3:17 PM** ----\> Madrid timezone (the same timezone defined on my profile) + 4 hours.

    * ![Screenshot 2022-05-12 at 11.50.29.png](https://community.atlassian.com/t5/image/serverpage/image-id/197024iB8C5639DCC332980/image-size/large?v=v2&px=999 "Screenshot 2022-05-12 at 11.50.29.png")

Tried changing **convertToTimeZone** to **SetTimeZone** expressions among many other combinations, but always get unexpected results. Not sure if al this is correcto and this is because of the viewer will always see the datetime on local time; if Im doing something wrong; there is a config that overwrites/mess-up my calculations... or it this post does make any sense at all :)

This is a key setup I need as I have multiple projects and countries all over the world so want to make sure the timezone are always correct, irrespective of creator or system config.... Any hint?

Thanks in advance,

Esteban


Answers:
author: Bill Sheboy
body: Hi [@Esteban Borja Lopez](/t5/user/viewprofilepage/user-id/589696)

My understanding of the time zones, in regards to automation rules, is that they impact:

* date/time math when operating on different fields/smart values, such as with the diff() function
* and presentation of results as text, such as in a comment or email

For each individual user, I would expect presentation of date/times to match their profile.

Are you wanting all users to see the same time zone values, regardless of their physical location and profile settings?

Kind regards,  
Bill


Tags: cloud

timezone