Search Postgresql Archives

Re: Time Zone design issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment: signature.asc
Description: Digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux