Back to results for “Time & Internationalization (Intl API)”
JavaScript › Date, Time & Internationalization (Intl API)

Why does new Date(2026, 7, 8) represent August 8th, not July 8th?

Advanced

Answer

The Date constructor's month argument is zero-indexed (0 = January, 11 = December) for historical reasons, so month 7 means the 8th month, August — a very common source of off-by-one date bugs.
const d = new Date(2026, 7, 8);
console.log(d.getMonth()); // 7
console.log(d.toDateString()); // 'Sat Aug 08 2026'
Real-world example A recurring bug class where developers pass the human month number directly and get the wrong month.

Common follow-ups: Does Intl.DateTimeFormat or Temporal also use zero-indexed months?