-1

I'm simply trying to get the current month. As of today when I post this, it's August 3rd... so why is the month logging as 7 instead of 8?

If I log date, it says "Aug 3rd". But when I log month, it says 7.

const date = new Date();
console.log(date) // logs "Tues Aug 3rd....
const year = date.getFullYear();
let month = date.getMonth();
console.log(month); // logs 7 <---- why?
Adam Norton
  • 512
  • 2
  • 5
  • 21
  • [JS Months start at 0](https://www.google.com/search?q=javascript+month+wrong+site%3Astackoverflow.com) – mplungjan Aug 03 '21 at 06:39
  • answered: https://stackoverflow.com/questions/2552483/why-does-the-month-argument-range-from-0-to-11-in-javascripts-date-constructor – manisha Aug 03 '21 at 06:43

1 Answers1

1

Javascript month begins at 0 not 1

Rova Ram
  • 166
  • 1
  • 3