I have an issue, and I don´t know what is wrong.
new Date(2017,3,31).getDate()
returns 1 (like 1.4., not 31.3.)
new Date(2017,3,30).getDate()
returns 30 (as 30.3.), which is correct.
Am I missing something?
Months in JavaScript are zero-based, so Date(2017,3,31) is actually April 31st, which doesn't exist. So you end up with May 1 instead.
You probably expect 3 to be March as it is the third month of the year.
JavaScript months start at 0:
0 - January
1 - February
2 - March
...
You are trying to create the April 31st, which does not exist. Change it to:
new Date(2017, 2, 31).getDate(); // March 31st
0forJanuary, and ends with11forDecemberMDN: Date3is April and there is no April 31st. Always read the MDN documentation.