wowprompt

Time zone and date handling fix for stored timestamps

Reviews how code stores, converts and displays dates and times, finds the bugs that make orders, bookings or reports land on the wrong day, and returns fixed code with tests across time zones and daylight saving changes. Use it when users in another country see wrong times, daily reports miss late-night orders, or scheduled jobs fire an hour off.

A list of date and time bugs with file, line and cause, corrected code that stores UTC and converts at the edges, and a test table covering tricky dates
The output this prompt produced, unedited.

The prompt

What to give

  • Code that creates, stores, compares or displays dates: [paste]
  • Language, framework and database: [e.g. Python with PostgreSQL, JavaScript with MySQL]
  • Database column types: [e.g. DATETIME, TIMESTAMP WITH TIME ZONE, string]
  • Where users and servers are: [e.g. server in UTC, users in India, UAE and the UK]
  • The symptom: [e.g. orders placed after 11:30 pm appear in the next day's report]

Task

Find every date and time bug in the code and fix it.

Review checklist

  1. Timestamps stored in UTC, or with their offset, never as local time without a zone.
  2. Conversion to the user's zone only when displaying or reading user input.
  3. Day boundaries for reports and limits computed in the business time zone, not the server's.
  4. Date-only values, such as birthdays and due dates, kept as dates and never shifted by a zone.
  5. Scheduled jobs defined in a named zone where daylight saving applies, such as Europe/London.
  6. Parsing that names its format; no reliance on the default locale.
  7. Comparisons between values in the same zone and type.
  8. Zones that are not a whole hour from UTC, such as India at UTC+5:30, handled correctly.

Output format

  1. | File and line | Bug | Example of wrong result | Fix |
  2. Corrected code in one block per file.
  3. A migration note if stored data must be converted, with a backup step first.
  4. | Test case | Input | Expected result |, including 23:59 local time, a daylight saving change night and a leap day.

Guardrails

  • Use the standard date library of the language; do not hand-roll offset arithmetic.
  • Do not change stored data without a reversible migration.
  • Say clearly when a fix changes how existing records will display.
time zone bugsutc timestampsdate handlingdaylight savingdatetime code reviewscheduling bugs

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity