timezone SQL Origin: Data OSI layer 7 · Application Last updated 18 Nov 2026

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.

Exact message you may see timestamps off by 5 hourstimezone conversion wrong SQLtime stored in UTC shows wrong hourtimestamp without time zone shiftedDST off by one hour SQL
Seen on: SQL PostgreSQL MySQL

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 zone interpreted as local
  • Session timezone differing from the app's
  • DST transition (ambiguous/non-existent hour)
  • NOW() returning server local time

⚡ Quick fix

  1. Store UTC and convert at the edge
  2. Use timestamptz / AT TIME ZONE
  3. Set the connection time zone consistently

Detailed fix by platform

SQL

  1. SELECT created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Asia/Kolkata' FROM events;

How to diagnose

  1. Column — Timestamp with time zone?
  2. Session TZ — Known?
  3. 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:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

1292 — MySQL ERROR 1292 (22007): Incorrect datetime value: 'x' for column 'y' (MySQL)129222008 — ERROR: date/time field value out of range: "31/12/2024" — HINT: Perhaps you need a different "datestyle" setting. (PostgreSQL)22008cartesian — Query returns far too many rows: accidental Cartesian product (missing JOIN condition) (SQL)cartesianCASE — CASE expression returns mixed types: conversion failed / types cannot be matched (SQL)CASECOUNT — COUNT(column) ignores NULLs: counts differ from COUNT(*) (SQL)COUNTdate format — Dates mixed up: dd/mm/yyyy vs mm/dd/yyyy, ISO 8601 recommended (SQL)date formatDECIMAL — Money/decimal values rounded wrongly: FLOAT precision and DECIMAL scale mistakes (SQL)DECIMALtimezone

Explore the map of this error Full error map →

🧠 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.