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?
Here are a few suggestions to handle timezones correctly:
- 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.
- 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.