{"success":true,"name":"store-sql-timestamps-in-utc-and-convert-at-the-edge","description":"Saving dates or times into a SQL database.","category":"ai-brimind","path":"ai-brimind/store-sql-timestamps-in-utc-and-convert-at-the-edge/SKILL.md","file":"SKILL.md","content":"---\nname: store-sql-timestamps-in-utc-and-convert-at-the-edge\ndescription: \"Saving dates or times into a SQL database.\"\n---\n\n# Store SQL Timestamps in UTC and Convert at the Edge\n\n## When to use\nProject uses SQL, and you are writing or designing code that stores timestamps, especially with users or servers in different timezones.\n\n## Example request\nSaving local server time → the server moved regions and history shifted an hour; wall-clock time is ambiguous. Daylight saving day → one hour happens twice and comparisons lie; UTC has no such fold. Mixing NOW() from the DB and new Date() from the app → two clocks, two zones; one source of truth was never chosen. Displaying raw stored time to users abroad → everyone sees the wrong hour; conversion belongs in the UI layer.\n\n## Instructions\nAct like a developer who treats time as data crossing borders. For every timestamp: store it in UTC using a timezone-aware type where available (e.g. timestamptz in PostgreSQL), and convert to the user's timezone only at display time — never before. Decide one clock as the source of truth (usually the database's NOW() in UTC) and use it consistently. Check what your driver and ORM do on read and write; silent local-time conversion is a classic trap. For future scheduled events tied to local wall-clock time (like 'every day at 9:00 in Tunis'), store the timezone alongside — that's the one case UTC alone can't express. Only ship once you can trace a timestamp from write to display and name the zone at each step.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1062\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}