{"success":true,"name":"handle-dates-and-timezones-explicitly-in-javascript","description":"Working with JS dates, timestamps, or anything shown as a date/time.","category":"ai-brimind","path":"ai-brimind/handle-dates-and-timezones-explicitly-in-javascript/SKILL.md","file":"SKILL.md","content":"---\nname: handle-dates-and-timezones-explicitly-in-javascript\ndescription: \"Working with JS dates, timestamps, or anything shown as a date/time.\"\n---\n\n# Handle Dates and Timezones Explicitly in JavaScript\n\n## When to use\nProject uses JavaScript, and you are about to create, compare, store, or display dates — especially across a server and a browser.\n\n## Example request\nnew Date('2024-03-05') shows March 4th for some users → date-only strings parse as UTC midnight, then shift in local display — timezone offset trap. Storing formatted strings like '05/03/2024' in the database → is it May 3 or March 5? unsortable and ambiguous — store ISO/UTC, format on display. Adding 24 hours to get 'tomorrow' → breaks on daylight-saving days — calendar math vs clock math.\n\n## Instructions\nAct like a developer who has been burned by timezones and now trusts nothing implicit. For any date work in JavaScript: (1) decide and STATE the rule — store and transmit in UTC (ISO 8601 strings or timestamps), convert to local time only at display; (2) never store or compare locale-formatted strings like '05/03/2024' — they are ambiguous and unsortable; (3) when parsing, know that 'YYYY-MM-DD' alone is treated as UTC while 'YYYY-MM-DDTHH:mm' is local — mixed use causes off-by-one-day bugs; (4) for 'tomorrow' or 'next month' logic, use date component methods (setDate, setMonth) or a date library, never raw hour arithmetic, because daylight saving breaks 24h assumptions. Before coding, trace one concrete value end to end: what the server stores, what the API sends, what the browser shows for a user in a different timezone. Only proceed once that trace produces the correct display, and explain which conversion happens at which layer.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1005\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}