Postgres Time Zones
Using Postgres when working with different timezones is great. Here's a small tip to help.
I was wondering today if there was a way to tell Postgres to default to a
particular time zone when setting or retrieving 'timestamp with time zone'
types. Using the SET... command seemed the way (at first), but after a
quick look at the Postgres documentation,
the PGTZ environment variable can be used to automatically set the
default timezone upon connection.
Then Martyn (in work) made a good suggestion which was to set the variable in the Apache configuration. So I did...
...except it didn't work - at first.
I tried setting it to one of NZST, CEST and UTC, though only the
latter worked. After reading a bit more and playing with tzselect, I
tried setting it to Europe/London and Pacific/Auckland it worked
perfectly. It seems to be very system dependent.
Once figured out, Postgres makes it all so easy. :-)
This post originated on http://chilts.org/.
Email me on andychilton -at- gmail -dot- com.
