Session level timezone in Postgres

postgres

You can set timezone at session level in Postgres using SET. It allows to override the server-level timezone for a specific session.

SET timezone = 'US/Pacific';

You can use the SELECT statement to verify the current timezone by executing:

SELECT current_setting('timezone');
+-----------------+
| current_setting |
|-----------------|
| US/Pacific      |
+-----------------+

Now, the datetime columns being returned from the database will match the set timezone (Us/Pacific here).



Stay up to date

Get notified when I publish something new, and unsubscribe at any time.