Re: Time Zone design issues - Mailing list pgsql-general

From novnov
Subject Re: Time Zone design issues
Date
Msg-id 12595616.post@talk.nabble.com
Whole thread Raw
In response to Re: Time Zone design issues  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Time Zone design issues
Re: Time Zone design issues
Re: Time Zone design issues
List pgsql-general
Yes, but there are still some parts of this I don't understand. From the
application user's perspective, the datetime a record was last updated needs
to be presented in their local time, in the browser. I have never been
intimate with web apps that accomodate user profile time settings, but have
used many. They let you set your local timezone. Else the app presents UTC.
So, something internal to that app (joomla, drupal etc) must be optionally
adjusting datetimes presented to the users. That's what I was suggesting; I
think your reqly and the one prior to it suggest that these things are
somehow 'handled'. Tom Lane seemed to point to a param to use with tz and
I'm trying to figure that out.

As far as I can see, my original premis is correct, that I need to tweak the
stored datetime when returned for viewing in a browser to adjust for any
user's tz setting...I'd be wrong if browsers automatically adjust any
datetime for the requesting pc's tz setting. I don't think they do, else why
would web apps like joomla and drupal adjust the datetime presented to the
end user according to whatever they set at their tz?

Your explanation of now() and localtime() is good...but localtime() to
postgres acting as a web app db, wouldn't it just return the local time as
far as the server is concerned?


Martijn van Oosterhout wrote:
>
> On Mon, Sep 10, 2007 at 07:46:17AM -0700, novnov wrote:
>> But 'apps all know to adjust for TZ'; really? In this case I'm creating
>> the
>> app, I can't imagine that it will automatically know to adjust for TZ?
>> The
>> postgres function now() would output now as far as the server is
>> concerned
>> (per it's local time setting I suppose), but very surprising is there is
>> enough magic to report to user time as adjusted to their time zone as
>> recorded in the db?
>
> Look up the definition of the time() function. In UNIX time is measured
> in seconds since 1 Jan 1970 UTC. This is a number that is obvisouly the
> same no matter where you are in the world. The C library has a function
> called localtime() that does all the magic of converting to whatever
> you consider local time.
>
> The postgres function now() is the same: it returns a number of seconds.
> Only when you actually go to display it does it do the localtime()
> dance (internally) to make it look nice. That why you can set the
> timezone to whatever you like and everything works the same.
>
> I can log into a number of servers in the world and I just have it
> setup to export TZ="my timezone" and everything is in my timezone, no
> matter where the machine is or whatever anyone else on the machine is
> doing. It's not magic, just someone 30 years ago making the smart
> choice.
>
> Have a nice day,
> --
> Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
>> From each according to his ability. To each according to his ability to
>> litigate.
>
>
>

--
View this message in context: http://www.nabble.com/Time-Zone-design-issues-tf4411984.html#a12595616
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Postgresql 7.3 on Red Hat Enterprise 5 (Problem with SEMMNI, SEMMNS)
Next
From: Alvaro Herrera
Date:
Subject: Re: Time Zone design issues