On Tue, Oct 25, 2011 at 5:52 PM, Tom Allison wrote:
Just realized I have a nice problem.

using Postgresql...

When I save something via Rails to the table it's saved with a GMT
offset (so 12:00 becomes 16:00)
But the database is configured to save everything as GMT.

Which means -- when I query it via SQL it's coming back as now + 4
hours instead of just plain now.

Where/How do I get this back in sync?
In SQL Standard you set a client timezone using SET TIME ZONE, which
PostgreSQL supports.

Timezone can be set using the "timezone" configuration parameter,
which can be set in the file postgresql.conf, or in any of the other
standard ways described, such as set for each session using SET. There
are also some special ways to set it:

* The SQL command SET TIME ZONE sets the time zone for the session.

* The PGTZ environment variable is used by libpq clients to send a
SET TIME ZONE command to the server upon connection.

So you can set this on the client or the server, for the user,
explicitly and other ways.

Simon Riggs                   http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 7 | next ›
Discussion Overview
grouprubyonrails-talk @
postedOct 25, '11 at 4:53p
activeOct 28, '11 at 11:34p



site design / logo © 2022 Grokbase