-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Wrong timestamp to JavaScript date conversion #993
Comments
Again time issue :-) Perhaps it should be perfectly documented on wiki |
I do suggest to never use 'without time zone' but always with time zone. It does solve your problem as well. Could you supply tests that expose this problem? |
Also encountered this, but not sure it's a bug with node-postgres. Steps to reproduce...
Output
I suspect that because the column type of timestamp (without timezone) then the timestamp is stored as a 'local' value. When node-postgres reads it back there is no timezone info, and so creates the date using the default timezone of the machine running node. Changing the column definition to |
Right, and that is why you should always use 'with timezone' |
I've run into this bug as well. I did some investigation and it appears the root issue is that The postgres manual is unfortunately not very direct about what how
Therefore, for the driver to be consistent with the behavior of postgres, the node-postgres timestamp parsing should use that same The bug happens in the following code from the
In the above code, for a That way, if for example, someone wants to forego timezone's in their application's database entirely and work in exclusively UTC (or use a different timezone then their operating system), they can set their database
I've found the following works as a simple workaround for making
Adding the zero offset 'Z' suffix to the postgres default timestamp output format is sufficient to convince |
MY GOD! I was losing my mind. Many, many expletives later, I cannot thank you enough. @astitt-ripple |
@astitt-ripple Would it be possible to submit a PR or open an issue on https://github.com/bendrucker/postgres-date? |
Here is the snapshot about this documentation I don't know why this still has not been fixed it if the documentation has already changed. I think this is using a library deprecated or something like that |
node-postgress probably converts timestamp to Date object as it would be local time. However it is UTC time and should be treated like that if there is no timezone in the db.
The text was updated successfully, but these errors were encountered: