-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
timestamp without timezone is parsed as if it had a timezone #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
NOTE: timestamp without timezone is oid 1114 |
@brianc @strk @cdauth sorry i'm late to the discussion here. I just updated to the latest pg and was broken by this change. I may be missing something here, but i feel like the original behavior prior to this change was far superior. In our projects, we always store timestamps as UTC in the database, using the data type timestamp without timezone. The client code accessing the db may be running in any arbitrary timezone of course, and so we completely ignore timezones and just use Date.getTime() when comparing or otherwise manipulating timestamps, so everything is manipulated UTC as well. I think this is a fairly common pattern? However, with this change to pg, from a client with a non-UTC timezone if i store a timestamp and then read it back, i get a different value from getTime() because it has been shifted based on the local timezone. I do see the discussion in PR #237 (and I wasn't sure which thread to put this comment on... my apologies). I do not want to change all the database types to timestamp with timezone in the schema for several reasons:
I looked at overriding the timezone of the clients to be UTC, but there are issues with that:nodejs/node-v0.x-archive#3286 How do you propose we work around this? Thanks, |
If you can't have your application always run in UTC |
@spollack: I has the same issue as you, which is why I worked on #237. While I still think this should be fixed and will write the necessary tests for it as soon as I feel like doing that, I fixed the issue for myself by changing my database columns to The only difference between |
@cdauth thanks, that is good news regarding how TIMESTAMP WITH TIMEZONE fields work -- i had the same misunderstanding, thanks for clarifying. Let me dig into that. |
@cdauth i just tested this, and I don't see the behavior you describe. I created a table with a TIMESTAMP WITH TIMEZONE field (postgres 9.2.x). I then used pg@0.12.3 to write a value to that field. My local timezone is PST. The value that ended up in the database (as viewed from either psql or pgadmin) is: not sure why we got different results? |
I suppose because your Postgres client is set to the same timezone, so when displaying the value, it is converted back to your timezone. Try to |
Thanks all. I set my default timezone in postgresql.conf to UTC, and verified that my sessions are are indeed in that timezone. After that, i do see TIMESTAMP WITH TIMEZONE fields in UTC via psql or pgadmin, like: 2013-02-14 23:37:02.923835+00 At this point, i can get the behavior i want if i switch to TIMESTAMP WITH TIMEZONE and also switch sessions to UTC. Doing only sessions in UTC but with TIMESTAMP WITHOUT TIMEZONE doesn't get the desired results. |
Fields of type "timestamp without timezone" are still being parsed as if they had one.
The text was updated successfully, but these errors were encountered: