pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lynna Landstreet <lynna@spidersilk.net>
To: Frank Bax <fbax@sympatico.ca>
To: PgSQL-PHP Mailing List <pgsql-php@postgresql.org>
Subject: Re: Times and time zones
Date: Wed, 20 Jul 2005 21:12:31 -0400
Message-ID: <BF046EBF.1BA6F%lynna@spidersilk.net> (raw)
In-Reply-To: <5.2.1.1.0.20050720193421.03ef54d0@pop6.sympatico.ca>

On 7/20/05 7:36 PM, Frank Bax <fbax@sympatico.ca> wrote:

>> I've set the datatype for all the time/date columns to timestamp with time
>> zone, as it seems to be the only type that will store all the data I need,
>> but I was thrown a bit by the fact that PostgreSQL apparently then converts
>> all the times to GMT, setting the time zone to +00 accordingly. So if a user
>> enters July 20, 2005, 6:30 pm EDT (Eastern daylight savings time), it's
>> saved as 2005-07-20 22:30:00+00 rather than 2005-07-20 18:30:00-04.
>> 
>> Now, this is fine for comparing different times internally, but it's not so
>> good for outputting the times back to the user for them to view and edit.
>> I've now created a second column for each time which saves the time zone
>> they originally entered, but I'm having trouble converting the time back
>> from GMT to the original. I need to write a PHP function
> 
> Why use php when sql will do the job?
> 
> http://www.postgresql.org/docs/7.4/interactive/functions-datetime.html#FUNCTIO
> NS-DATETIME-ZONECONVERT

Aaagh! Can't believe I missed that! Thank you!

So to use this, I'd just add it to my select statement when retrieving the
data? As in "SELECT TIMESTAMP WITH TIME ZONE arrival_time AT TIME ZONE
arrival_time_zone, [and various other fields] FROM [table] WHERE
[condition]"?

And for the time zone value, can it take all the input types listed for
timezone in the datatypes section
(http://www.postgresql.org/docs/7.4/interactive/datatype-datetime.html#DATAT
YPE-TIMEZONE-TABLE), i.e. PST, -8:00, -800, -8, uniform, u?


Lynna

-- 
Spider Silk Design - http://www.spidersilk.net
509 St Clair W Box 73576, Toronto ON Canada M6C 1C0
Tel 416.651.2899 - Toll Free 1.866.651.2899 - Cell 416.873.9289




view thread (5+ messages)  latest in thread

Message-ID: <BF046EBF.1BA6F%lynna@spidersilk.net>
Permalink:  ../BF046EBF.1BA6F%25lynna@spidersilk.net/
Also on:    postgresql.org/message-id/BF046EBF.1BA6F%lynna@spidersilk.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: lynna@spidersilk.net, fbax@sympatico.ca
  Subject: Re: Times and time zones
  In-Reply-To: <BF046EBF.1BA6F%lynna@spidersilk.net>
  References: <5.2.1.1.0.20050720193421.03ef54d0@pop6.sympatico.ca> <BF046EBF.1BA6F%lynna@spidersilk.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox