Timestamps off by hours: timezone, UTC and DST conversion mistakes
Stored times appear shifted by 5 or 8 hours, or events shift around daylight saving changes.
timestamps off by 5 hourstimezone conversion wrong SQLtime stored in UTC shows wrong hourtimestamp without time zone shiftedDST off by one hour SQL Meaning
Store timestamps in UTC (timestamptz in PostgreSQL, UTC datetime elsewhere), convert at display time with the user's zone, and know the difference between timestamp and timestamp with time zone. Server, session and client timezones all matter.
Common causes
- Mixing local time and UTC in one column
timestamp without time zoneinterpreted as local- Session timezone differing from the app's
- DST transition (ambiguous/non-existent hour)
NOW()returning server local time
⚡ Quick fix
- Store UTC and convert at the edge
- Use
timestamptz/AT TIME ZONE - Set the connection time zone consistently
Detailed fix by platform
SQL
SELECT created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Asia/Kolkata' FROM events;
How to diagnose
- Column — Timestamp with time zone?
- Session TZ — Known?
- DST — Considered?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026