PostgreSQL · sdk · fg-0273

node-postgres shifts DATE and TIMESTAMP values by the Node process timezone

If you see A DATE of 2017-05-29 comes back as 2017-05-29T05:00:00.000Z in a process running at UTC-5, the cause and the fix for PostgreSQL are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
A DATE of 2017-05-29 comes back as 2017-05-29T05:00:00.000Z in a process running at UTC-5In zones ahead of UTC, DATE values read back as the previous day once converted with toISOStringIn zones behind UTC, writing a Date created at UTC midnight stores the previous calendar day
Cause
pg turns DATE and TIMESTAMP WITHOUT TIME ZONE values into JavaScript Date objects at local time in the Node process zone (the TZ variable), and formats Date parameters in that zone on the way in. Parsing DATE into a Date is kept only for backward compatibility.
Fix
Store instants as timestamptz, run Node with TZ=UTC, and keep DATE values as plain strings.
Apply
import pg from 'pg' pg.types.setTypeParser(1082, (v) => v) // DATE stays 'YYYY-MM-DD' // start the process with TZ=UTC
Affected
pg (node-postgres) 8.x, as of October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun