A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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.
PS. I tried with all available API versions in GraphiQL app. Also tried with ordinary graphQL request.
Solved! Go to the solution
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).
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
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).
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
Thank you for reply,
So timezoneOffsetMinutes is different from
new Date().getTimezoneOffset()
in JS.
That made me confused.
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