question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postgresql: Timestamp without time zone not treated as UTC when the database is configured to be in UTC by default

See original GitHub issue

The value in the database is 2017-06-01 10:00:00 and I would expect to get 2017-06-01T10:00:00.000Z, but instead KNEX treats the 10:00 as an hour in my server’s timezone (+3 GMT) and returns 2017-06-01T07:00:00.000Z

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
pineapplemachinecommented, Oct 4, 2018

I ran into this issue also, and was able to get the behavior I expected by adding this code before creating a knex client object:

const types = require("pg").types;
const TIMESTAMP_OID = 1114;
types.setTypeParser(TIMESTAMP_OID, function(value) {
    // Example value string: "2018-10-04 12:30:21.199"
    return value && new Date(value + "+00");
});
1reaction
elhigucommented, Jun 1, 2017

I’ll report this to node-postgres and let’s see if they are willing to change how it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a valid use case for using TIMESTAMP WITHOUT ...
An input value that has an explicit time zone specified is converted to UTC using the appropriate offset for that time zone.
Read more >
Difference between timestamps with/without time zone in ...
Without a time zone as part of the value, the obvious default time zone is UTC, so it is rendered for that time...
Read more >
Documentation: 15: 8.5. Date/Time Types - PostgreSQL
When a timestamp with time zone value is output, it is always converted from UTC to the current timezone zone, and displayed as...
Read more >
Mapping .NET Timestamps to PostgreSQL - Shay Rojansky
timestamptz is perhaps the worst-named type in the world: it does not, in fact, store a time zone in the database, but rather...
Read more >
Actually Understanding Timezones in PostgreSQL - Untrod
Remember that Postgres doesn't store time zones; it just normalizes tz-aware timestamps to UTC. Know what time zone your session is using. It ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found