javascript-utc-date-timezone-drift
Installation
SKILL.md
JavaScript UTC Date Timezone Drift Fix
Problem
When working with JavaScript Date objects that represent UTC times (e.g., from a database or API), using local time methods like getHours(), getMinutes(), or setHours() causes timezone drift. The browser automatically applies the user's local timezone offset, causing times to shift unexpectedly.
This creates silent bugs where:
- 09:00 UTC appears as 10:00 for users in BST (UTC+1)
- 09:00 UTC appears as 01:00 for users in PST (UTC-8)
- Times work correctly for developers in UTC but fail in production for global users
Context / Trigger Conditions
Use this skill when you see:
-
Time shift by timezone offset: A time stored as 09:00 UTC displays as 10:00, 01:00, or another value depending on user location
-
Inconsistent behavior across timezones: Times appear correct for some users but wrong for others