Strapi postgres remote conn to db in different tz would change datetime

System Information
  • **Strapi Version4:
  • Operating System:
  • **Databasepostgres:
  • **Node Version18:
  • NPM Version:
  • Yarn Version:

I have a setup where, I connect to remote postgres db from local instance of strapi to test and develop.
For some reason, all my datetime entries were showing a lag based on local tz.

As strapi stores all date time as UTC.( I verified even through pgadmin to ensure db has correct entry in timestamp without timezone type field)

Apparently pg connection was at fault here and was inadvertently trying to autocorrect pg created_at timestamp without timezone, unless it is set to only respond as UTC.
Unfortunately setting timezone: ‘utc’ in postgres connection in database.js doesnt resolve this issue.

After some digging around, I found that pg uses env var to correct the tz and we can set TZ=UTC in .env to ensure that pg doesnt send request to postgres to tz correct these fields.

Solution: set TZ=UTC in .env file

hopefully this helps someone.