GraphQL Bug: Incorrect timezoneOffsetMinutes

Solved

GraphQL Bug: Incorrect timezoneOffsetMinutes

adkhamllama
Shopify Partner
24 0 49

Hello.
I was doing a request to get shop timezoneOffsetMinutes via GraphQL and noticed that timezoneOffsetMinutes returns me inverted number. I have set the Store's timezone to GMT -05:00 (EST), which should return me 300, but it returns -300. Same for other timezones. I guess it is a bug with graphQL.

adkhamllama_0-1706082297575.png

adkhamllama_1-1706082320522.png

PS. I tried with all available API versions in GraphiQL app. Also tried with ordinary graphQL request.

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 498

This is an accepted solution.

Hey @adkhamllama,

 

That looks like the expected behaviour for the timezoneOffsetMinutes field calculating the time in EST, the UTC-5:00 timezone, which is offset from Coordinated Universal Time by (-5 hours * 60 minutes).

 

  • An offset of 300 would correspond to a city in the UTC+5:00 timezone, so 10 hours ahead of the shop in your screenshot.

 

You should be able to use that field to calculate a shop's local time, like this for example in Ruby:

 

Hope that helps!

 

- James

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 238 498

This is an accepted solution.

Hey @adkhamllama,

 

That looks like the expected behaviour for the timezoneOffsetMinutes field calculating the time in EST, the UTC-5:00 timezone, which is offset from Coordinated Universal Time by (-5 hours * 60 minutes).

 

  • An offset of 300 would correspond to a city in the UTC+5:00 timezone, so 10 hours ahead of the shop in your screenshot.

 

You should be able to use that field to calculate a shop's local time, like this for example in Ruby:

 

Hope that helps!

 

- James

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

adkhamllama
Shopify Partner
24 0 49

Thank you for reply,
So timezoneOffsetMinutes is different from 

new Date().getTimezoneOffset()

 in JS.
That made me confused.

ShopifyDevSup
Shopify Staff
1453 238 498

Hey @adkhamllama,

 

Thanks for pointing that out, I think I understand the source of the confusion now. 

 

The timezoneOffsetMinutes field in the Admin API references the Shop.ianaTimezone, however JavaScript handles the offset in the opposite way, which can definitely throw people off.

 

Cheers,

 

- James

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog