DATE004warningPro

getday-utc-mismatch

Local-timezone Date getter used in a file that works with UTC dates

Applies to: JavaScript, TypeScript

Why this matters

Methods like .getDay(), .getHours(), .getDate(), .getMonth(), and .getFullYear() return values in the server's local timezone. When working with UTC dates, this silently returns wrong values. For example, 2024-01-15T00:00:00Z.getDay() returns Sunday in UTC-5 but Monday in UTC. Use the UTC variants (.getUTCDay(), .getUTCHours(), etc.) instead.

Catch it before it ships

pip install stablestack # or: npx stablestackstablestack # scans your project, DATE004 includedstablestack explain DATE004

DATE004 is part of the Pro rule set. See pricing — the free tier ships 24 checks with no signup.

False positive in your codebase? Suppress a single line with # noqa: DATE004