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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing TIMESTAMP WITHOUT TIME ZONE as local time #1071

Closed
skatcat31 opened this issue Jul 8, 2016 · 4 comments
Closed

Parsing TIMESTAMP WITHOUT TIME ZONE as local time #1071

skatcat31 opened this issue Jul 8, 2016 · 4 comments

Comments

@skatcat31
Copy link

When I get a return of a TIMESTAMP WITHOUT TIME ZONE I get it in local time instead of in UTC like it was stored(hence no time zone). Is there a reason for this or should it be addressed?

@arypurnomoz
Copy link
Contributor

i also got this problem

@jondayft
Copy link

See this issue for more info on this #818

@brianc
Copy link
Owner

brianc commented Jul 14, 2016

There's a reason for this - it comes up about once a year in an issue here and on node-pg-types - basically the tl;dr is we bike shedded on this hard a few years ago & came up with this being the right solution, but the details are in issue #818. (thanks for pointing that out @jondayft!)

The good news is you can override the behavior very easily in node-pg-types to parse dates any way you want, use moment.js to parse them, leave them as strings, anything!

@brianc brianc closed this as completed Jul 14, 2016
@elhigu
Copy link

elhigu commented Jun 10, 2017

I actually wasn't able to find any reasons why timestamp without timezone is parsed to local time and not to UTC from #818 (this comes up every now and then in knex issues).

Sounds like it was an old decision maybe because when you pass Date object as an input and then read it with query and parse it back to Date object, the date value remains the same.

Also postgresql spec seems agree that timestamp without timezone is local timestamp

Conversions between timestamp without time zone and timestamp with time zone normally assume that the timestamp without time zone value should be taken or given as timezone local time. A different time zone can be specified for the conversion using AT TIME ZONE.

https://www.postgresql.org/docs/9.2/static/datatype-datetime.html

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

No branches or pull requests

5 participants