Advertisement
Advanced JavaScript, Date, Time & Internationalization (Intl API)

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

Short 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.

Save JavaScript mock interview
Advertisement
AModel 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.
Likely follow-ups
  • Does Intl.DateTimeFormat or Temporal also use zero-indexed months?
Related topics