Skip site navigation (1) Skip section navigation (2)

Confused by timezones

From: Alessio Bragadini <alessio(at)albourne(dot)com>
To: SQL for PostgreSQL list <pgsql-sql(at)postgresql(dot)org>
Subject: Confused by timezones
Date: 2000-12-15 12:23:40
Message-ID: 3A3A0D4C.E80E6C12@albourne.com (view raw or flat)
Thread:
Lists: pgsql-sql
Sorry, I am trying to find my way in formatting timestamps for different
timezones and I am a little confused.

[ PostgreSQL 7.0.0 on alphaev6-dec-osf4.0f, compiled by cc ]

Let's imagine 
CREATE TABLE tztest (id SERIAL, v TEXT, ts TIMESTAMP DEFAULT now());

How can I format a 
SELECT to_char(ts,'DD/MM/YYYY HH:MI:SS')
in order to have the accompanying timezone for the timestamp?
If I select the ISO format, I ofcourse have it ('2000-12-15
13:09:59+02')
but I cannot find a to_char element for it, either in offset or codes
(which I'd prefer). 
Is this possible?

On a more general ground, I checked the 'Date/Time Data Types' section
of the user manual, but I don't manage to have the expected behaviour,
with either the PGTZ env variable or the SET TIMEZONE command. Here's an
example (my default is EET i.e. +02):

village=# select ts from tztest;
           ts
------------------------
 2000-12-15 13:09:59+02
(1 row)
 
village=# set TimeZone TO PST;
SET VARIABLE
village=# select ts from tztest;
           ts
------------------------
 2000-12-15 13:09:59+02
(1
row)                                                                         

or maybe I just don't understand the whole picture...

P.S. Ofcourse I can use external functions, e.g. Date::Manip since I
code in Perl, but I'd prefer to leave this task to the database itself.

-- 
Alessio F. Bragadini		alessio(at)albourne(dot)com
APL Financial Services		http://village.albourne.com
Nicosia, Cyprus		 	phone: +357-2-755750

"It is more complicated than you think"
		-- The Eighth Networking Truth from RFC 1925

Responses

pgsql-sql by date

Next:From: Karel ZakDate: 2000-12-15 12:45:17
Subject: Re: Confused by timezones
Previous:From: miguel soferDate: 2000-12-15 12:13:08
Subject: Re: How to represent a tree-structure in a relationaldatabase

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group