Is there a way to set a different time zone as the default for a session?

By default, Postgres displays my data stored in "TIMESTAMP WITH TIME ZONE" columns' data as a local time for the time zone of the computer hosting the Postgres cluster.

If my Postgres server is in Seattle, but my user is in New York, I want the times shown in New York time zone.

I know about using the "AT TIME ZONE" command. But:

(a) I would rather set the time zone once in each database connection/session rather than include it in all my individual SQL calls.

(b) When using "TABLE myTable;" or "SELECT * FROM myTable;", I cannot specify "AT TIME ZONE".

--Basil Boruque

Search Discussions

  • Tom Lane at Jan 28, 2011 at 3:30 pm

    Basil Bourque writes:
    Is there a way to set a different time zone as the default for a session?
    There are lots of ways. See
    http://www.postgresql.org/docs/8.4/static/config-setting.html

    regards, tom lane
  • Jasen Betts at Jan 29, 2011 at 3:32 am

    On 2011-01-28, Basil Bourque wrote:

    Is there a way to set a different time zone as the default for a session?
    By default, Postgres displays my data stored in "TIMESTAMP WITH TIME
    ZONE" columns' data as a local time for the time zone of the computer
    hosting the Postgres cluster.

    If my Postgres server is in Seattle, but my user is in New York, I
    want the times shown in New York time zone.
    -- once per session.
    SET TIMEZONE TO 'America/New_York';

    -- or once only
    ALTER USER username SET TIMEZONE TO 'America/New_York';

    or you can do the whole database with ALTER DATABASE.


    --
    ⚂⚃ 100% natural

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedJan 28, '11 at 4:54a
activeJan 29, '11 at 3:32a
posts3
users3
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase