Why does Apollo Explorer return timestamp 2 hours earlier than my actual timezone?

Hello team,

I am using keystoneJS, which provides GraphQL as API, also an Explorer for developers to write their queries and mutations.
Now I noticed that whenever i return data which has a timestamp, it returns two hours earlier than my actual timezone.

is there a way to set the correct timezone for the Apollo Explorer?


Apollo Explorer itself does not provide a direct way to set the timezone. The timezone issue you’re experiencing is likely due to how the data is stored or retrieved in KeystoneJS, or how JavaScript is handling the Date objects.

Here are a few suggestions to handle timezones correctly:

  1. Use UTC for storing dates in the database:

Store all dates in your database as UTC. This way, you have a consistent, unambiguous format to work with.

  1. Convert dates to the desired timezone in your resolvers:

When retrieving data in your GraphQL resolvers, convert the dates to the desired timezone before returning them. You can use the luxon library to handle timezone conversions easily.

Thank you @mkdangi21 will try this also maybe converting the timestamp with Javascript Date functions, as last resort.

1 Like