{"action":"created","issue":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/1150","repository_url":"https://api.github.com/repos/brianc/node-postgres","labels_url":"https://api.github.com/repos/brianc/node-postgres/issues/1150/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-postgres/issues/1150/comments","events_url":"https://api.github.com/repos/brianc/node-postgres/issues/1150/events","html_url":"https://github.com/brianc/node-postgres/issues/1150","id":182844400,"number":1150,"title":"Q: passing Date() variable as parameter to client.query()","user":{"login":"jdabbs003","id":13259829,"avatar_url":"https://avatars.githubusercontent.com/u/13259829?v=3","gravatar_id":"","url":"https://api.github.com/users/jdabbs003","html_url":"https://github.com/jdabbs003","followers_url":"https://api.github.com/users/jdabbs003/followers","following_url":"https://api.github.com/users/jdabbs003/following{/other_user}","gists_url":"https://api.github.com/users/jdabbs003/gists{/gist_id}","starred_url":"https://api.github.com/users/jdabbs003/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdabbs003/subscriptions","organizations_url":"https://api.github.com/users/jdabbs003/orgs","repos_url":"https://api.github.com/users/jdabbs003/repos","events_url":"https://api.github.com/users/jdabbs003/events{/privacy}","received_events_url":"https://api.github.com/users/jdabbs003/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/brianc/node-postgres/labels/question","name":"question","color":"f9d0c4"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-13T16:56:57Z","updated_at":"2016-10-19T10:33:27Z","closed_at":null,"body":"Question: What are best practices for passing **Date** objects as _client.query()_ parameters for _TIMESTAMP WITH TIME ZONE_ and _TIMESTAMP WITHOUT TIME ZONE_ values?\r\n\r\nAlso, when passing a **Date** object as a _TIMESTAMP WITH TIME ZONE_ value, is **getTimezoneOffset()** used to synthesize the actual time zone passed on the wire to postgres?"},"comment":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/comments/254775648","html_url":"https://github.com/brianc/node-postgres/issues/1150#issuecomment-254775648","issue_url":"https://api.github.com/repos/brianc/node-postgres/issues/1150","id":254775648,"user":{"login":"joskuijpers","id":5017040,"avatar_url":"https://avatars.githubusercontent.com/u/5017040?v=3","gravatar_id":"","url":"https://api.github.com/users/joskuijpers","html_url":"https://github.com/joskuijpers","followers_url":"https://api.github.com/users/joskuijpers/followers","following_url":"https://api.github.com/users/joskuijpers/following{/other_user}","gists_url":"https://api.github.com/users/joskuijpers/gists{/gist_id}","starred_url":"https://api.github.com/users/joskuijpers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joskuijpers/subscriptions","organizations_url":"https://api.github.com/users/joskuijpers/orgs","repos_url":"https://api.github.com/users/joskuijpers/repos","events_url":"https://api.github.com/users/joskuijpers/events{/privacy}","received_events_url":"https://api.github.com/users/joskuijpers/received_events","type":"User","site_admin":false},"created_at":"2016-10-19T10:33:27Z","updated_at":"2016-10-19T10:33:27Z","body":"I just pass them. Simply. Just `query(\"SELECT $1::timestamptz\", [myDate])` (or timestamp when not using a time zone).\r\n\r\nYou can see the date parse implementation here: https://github.com/brianc/node-pg-types/blob/master/lib/binaryParsers.js#L132\r\nIn the code you can see that only when using timestamptz the timezone within is used. If using timestamp (without timezone), only date and time is stored and the timezone is assumed to be the local one. So when storing in postgres the timezone is lost, and when getting from postgres the local timezone is assumed.\r\n\r\nI advise to _always_ use timestamps with time zone. It is very useful information and fixes (and prevents) problems when time zones differ, either on the client side, or between pg client and pg server."}}
{"actor":{"display_login":"joskuijpers"}}