Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse date type as local time #514

Merged
merged 1 commit into from Feb 26, 2014
Merged

Conversation

benighted
Copy link
Contributor

Resolves issue #510, but is a breaking change. Handle with care 馃槃
Updated failing test case as well.

@jrf0110
Copy link
Contributor

jrf0110 commented Jan 27, 2014

馃憤 Woot!

@brianc
Copy link
Owner

brianc commented Feb 26, 2014

Thank you so much @benighted

Sorry for the delay here - going to try to get pg @ 3.0 out asap

brianc added a commit that referenced this pull request Feb 26, 2014
@brianc brianc merged commit 2716f95 into brianc:master Feb 26, 2014
@benighted benighted deleted the parse-date-as-local branch February 27, 2014 18:25
@brianc brianc added this to the v3.0 milestone Mar 12, 2014
@alejandrolsca
Copy link

alejandrolsca commented Nov 21, 2017

@brianc is there a way to set the timezone in node-postgres? I tried to find it in the documentation without success, i found an environment variable PGTZ here https://www.postgresql.org/docs/current/static/libpq-envars.html but i had not success trying to guess the configuration in the pool connection i.e.
const pool = new Pool({ connectionString: '......', timezone: 'America/Chihuahua' })
also tried to set the timezone with a query as follows
await client.query("SET timezone = 'America/Chihuahua';")
but didn't worked, it works in the DBMS(navicat in this case)
in fact what im trying to do is to set the timezone dynamically(i need it at the client/query level not at global level), so the query will be at the end as follows
await client.query("SET timezone = $1;")

can you give me start point to solve this issue, maybe im not looking in the right place. Thanks in advance for your support

@jrf0110
Copy link
Contributor

jrf0110 commented Nov 21, 2017

@alejandrolsca generally you'd use something like at time zone $1 in your queries:

-- Display the timestamp in the timezone of the object
select
  orders.created_at at time zone orders.timezone
from orders

@alejandrolsca
Copy link

alejandrolsca commented Nov 21, 2017

@ jrf0110 I was aware of that way of doing it, so its not recommended to use SET timezone .....? at this moment looks like a good solution, but in the near future could i have some problems? scalability issues? just wonder, also still wondering why SET timezone .... did not work, even if you call that query in node postgres it gets overriden by postgres.conf?

@jrf0110
Copy link
Contributor

jrf0110 commented Nov 21, 2017

I believe SET timezone will simply set the timezone the database is in (which will affect how dates are created). Try something like:

set timezone = 'America/Chicago';
select now();

@alejandrolsca
Copy link

alejandrolsca commented Nov 21, 2017

@jrf0110 well the problem here is that it doesn't work in node-postgres, at least not for me, if I execute those queries in DBMS it works, but not by doing it with node-postgres library as follows:
client.query("SET timezone = 'America/Chihuahua';");
client.query("My query with dates here");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants