Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

If I want get Ubuntu system time, I have two options:

$ cat /etc/timezone
US/Eastern

$ date
Sun Sep 15 14:45:02 EDT 2013

How can I find out if PostgreSQL is using utc or a utc offset, such as US/Eastern?

share|improve this question

2 Answers 2

You can use current_setting() function to get the TIMEZONE setting.

SELECT current_setting('TIMEZONE') TZ;

Sample output:

# SELECT  current_setting('TIMEZONE') TZ;
     tz     
------------
 US/Eastern
(1 row)

Here is SQLFiddle demo

share|improve this answer

To see all relevant settings for local time (and some irrelevant, too), you can use:

SELECT * FROM pg_settings
WHERE name ~* 'time'

In particular, the settings for TimeZone and lc_time should be of interest to you. (The time zone is not the only relevant detail for time format.) You get a short description in the column short_desc.) More details for these settings in the manual here.

If you are only interested in one particular setting, the shortest form is:

SHOW timezone;

Returns the same as SELECT current_setting('timezone') (like peterm provided), but the latter can also be integrated into DML SQL queries.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.