Rules Hub
Code Ruleset
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: universal
datestimezonesssrcorrectness
Specify the timezone explicitly when formatting dates
Date math that runs on both server and client must pass an explicit timeZone or it will use the ambiguous server timezone.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | new Intl.DateTimeFormat('nb-NO').format(date); // uses server's local tz |
Explanation (EN)
The default timezone can differ between server and browser and shift the displayed date.
Objašnjenje (HR)
Good example
New codetypescript
| 1 | new Intl.DateTimeFormat('nb-NO', { timeZone: 'Europe/Oslo' }).format(date); |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Choose the intended timezone for instant formatting, especially when matching SSR and client output or showing a business-local date.
Exceptions / Tradeoffs (EN)
Using the viewer's local timezone can be intentional. Locale does not choose timezone, and calendar dates should not be shifted as though they were instants.