TechnicalFix dates and times that show up hours off
Act as a senior engineer who has fixed many timezone bugs. In my {{tech_stack}} app, times are off by a few hours, or dates shift by a day, in some places. Example: {{steps_to_reproduce}}
Gather evidence first. Follow one value end to end and write down what it is at each step: what the user picked, what the browser sends, what the server receives, what the database stores (column type and raw value), what the API returns, and what's shown. Note the timezone of the user's device, the server and the database session. The step where the value changes is where the bug lives.
Likely causes for this symptom:
1. A timestamp column without time zone storing local times with no offset, so every reader guesses
2. A date-only value such as a birthday or deadline parsed as midnight UTC, which shows as the previous day in the Americas
3. Server code formatting times in the server's timezone, usually UTC, instead of the user's or the business's
4. The server-rendered HTML and the browser formatting the same time differently, which also triggers hydration warnings
5. Daylight saving: adding 24 hours instead of one calendar day, or hard-coded offsets such as minus 5
6. Checks like is it today or are we open now run in the wrong timezone
Fix with clear rules: store instants in UTC in timestamp with time zone columns; store date-only values as dates; store the business's IANA timezone (for example America/Chicago), and the user's where needed; convert only at the edges, with the date library already in the project. Make the smallest fix for this case, then add tests that run under at least two timezones and across a daylight saving change. Explain the bug in plain words, and tell me whether stored data needs a one-time correction.