Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set PostgreSQL's internal clock?

Posted on 2004-09-02
10
Medium Priority
?
933 Views
Last Modified: 2008-02-26
Hi.

I get the PostgreSQL internal time using this command: "SELECT CURRENT_TIMESTAMP". But since I installed PostgreSQL 8.0 Beta 1 on my windows I get different times between system time and PostgreSQL time.
How to set PostgreSQL's internal clock?

Thanks.
0
Comment
Question by:pepoclv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
10 Comments
 

Author Comment

by:pepoclv
ID: 11967550
Look at this example:

Windows system time displays: 09/02/2004 4:53pm

PostgreSQL command "SELECT CURRENT_TIMESTAMP" returns: 09/02/2004 2:24pm
0
 
LVL 2

Expert Comment

by:brozzis
ID: 11967633

AFAIK there is no internal clock in postgreSQL., it shouldn't make any sense.
I suppose it's the reason why it is still a beta version.

On my 7.4.2 works as expected, returning the system time.

0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 252 total points
ID: 11967736
Might be because the time set to some other timezone specification.

SET TIME ZONE LOCAL;  
will set the time zone to your local time zone (the one that the server's operating system defaults to) and then run

SELECT CURRENT_TIMESTAMP;
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 2

Expert Comment

by:brozzis
ID: 11967837

In that case I'd expect a different hour, or half hour, not a complete different time.

...I've noticed right now that between 4:53 and 2:24  there's a difference of 2h29m,
that could lead the solution to a matter of time zones...

0
 
LVL 22

Assisted Solution

by:earth man2
earth man2 earned 248 total points
ID: 11968493
You really need to define local timezone in postgresql.conf.  For me in GB I always use the following.

If you don't it returns UTC AFAIK

# - Locale and Formatting -

datestyle = 'sql, dmy'
timezone = 'Europe/London'              # actually, defaults to TZ environment setting
0
 

Author Comment

by:pepoclv
ID: 11972219
Now I know that the problem is time zone. I tryed to set local timezone doing this: SET TIME ZONE 'GMT-3'; but it did not work.
When I run SELECT CURRENT_TIMESTAMP; it returns "2004-09-03 12:47:28.093-00".
0
 
LVL 22

Expert Comment

by:earth man2
ID: 11972312
dev=# set session timezone to -3;
SET
dev=# select current_timestamp, current_timestamp at time zone 'BST';
          timestamptz          |          timezone          
-------------------------------+----------------------------
 03/09/2004 10:05:51.652133-03 | 03/09/2004 14:05:51.652133
(1 row)

0
 
LVL 22

Expert Comment

by:earth man2
ID: 12063608
I think pg_tzset  look in directory /usr/share/postgresql/timezone   GMT-3 is in the "Etc" subdirectory so this works.

dev=> set session timezone to 'Etc/GMT-3';
SET
dev=> select current_timestamp, current_timestamp at time zone 'BST';
           timestamptz           |         timezone          
---------------------------------+---------------------------
 15/09/2004 15:12:13.14708 GMT-3 | 15/09/2004 13:12:13.14708
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question