when i wanna to extract a Month value i got an incorrect value :
date2 = new Date('Mon Dec 22 2014 00:00:00 GMT+0000 (Maroc)')
date2.getMonth() // --> i got 11 !!
i can increase the value by one but is not the best the solution
Any help please
when i wanna to extract a Month value i got an incorrect value :
date2 = new Date('Mon Dec 22 2014 00:00:00 GMT+0000 (Maroc)')
date2.getMonth() // --> i got 11 !!
i can increase the value by one but is not the best the solution
Any help please
The getMonth() function starts at zero.
Therefore, January will return zero and December will return 11.
You can read more about the date object and the getMonth function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth
The getMonth() return value is zero-based.
Quoting the docs
The value returned by
getMonth()is an integer between 0 and 11. 0 corresponds to January, 1 to February, and so on.