ISO Week Number in JavaScript
Updated: May 2026
JavaScript has no built-in ISO week method, but the algorithm is straightforward. The key is to work in UTC to avoid timezone-induced day shifts, and to treat the ISO year as independent from the calendar year for dates near year boundaries.
Free · No upload · 100% in-browser
Core algorithm — date to ISO week
The standard approach: shift the date to the nearest Thursday (the anchor day of the ISO week), then count how many complete weeks have passed since the start of that Thursday's year.
The function returns both week and year. Always use the returned year, not date.getFullYear(). For a date like December 31, 2018, the ISO year is 2019 even though the calendar year is 2018.
Why use UTC methods?
JavaScript's local-time methods (getDay(), getDate(), etc.) apply the browser's timezone offset. In a UTC+12 timezone, a UTC midnight boundary becomes noon the previous day locally. This can push a date one day backward, landing it in the wrong ISO week. Using Date.UTC() and the getUTC* family eliminates this risk — dates are treated as timezone-neutral day values.
ISO week to Monday date
To find the Monday of a given ISO year and week:
January 4 is always in ISO week 1. The Monday of the week that contains January 4 is the Monday of week 1. From there, adding multiples of 7 days reaches any target week's Monday.
Using Intl.DateTimeFormat (modern approach)
Modern browsers support locale-aware week formatting via Intl.DateTimeFormat with the weekInfo option, but ISO week number as a format field is not yet standardized. A more reliable modern approach uses Temporal (TC39 Temporal proposal, available in some environments):
Until Temporal is universally available, the UTC-based manual algorithm above is the safest cross-browser solution without adding a dependency like date-fns or Luxon.
Counting ISO weeks in a year
A year has 53 ISO weeks if and only if December 28 of that year falls in week 53: