I'm running following query from my JS code using pg:
SELECT begin_at, to_char(begin_at, 'DD.MM') AS dt
FROM tasks
WHERE begin_at >= $1
ORDER BY begin_at
Column begin_at has type timestamptz.
On my PC I get dates in my timezone (UTC+4)
{ begin_at: "2021-11-02T19:00:00.000Z", dt: "03.11" } and on server I get { begin_at: "2021-11-02T19:00:00.000Z", dt: "02.11" } for the same database.
Both running node v16.8.0, postgres 13, both have same time and set postgres timezone to Asia/Yekaterinburg
SET TIMEZONE = 'Asia/Yekaterinburg'; SELECT to_char('2021-11-02T19:00:00.000Z'::timestamp with time zone, 'DD.MM') AS dt?to_char(begin_at AT TIME ZONE 'Asia/Yekaterinburg', 'DD.MM') AS dt. Also I'd be curious what the result ofto_char(begin_at, 'TZ') AS tzis in your two systems.AT TIME ZONE. Apparently the only way to influence rendering timezone into_charis toset local timezone to '…'. I really would suggest to just query the timestamp from postgres, and do the date formatting in the last possible moment; in your case using a timezone-aware date library (e.g. Temporal or Luxon) in node.js.timestamp(without timezone)? That actually suffers from worse problems, as now the values change (and not just the formatting) when you have a different session timezone.