There seems to be an error with the Date object in Javascript, it thinks April 31, 2017 is a real day. I discovered this by trying to get the date 90 days ago from today (August 29). The following is a snippet of my code for context:
*Edit: For context, this is in Google Apps Script technically.
var now = new Date();
var ninetyDaysAgo = new Date(now.getTime() - 90 * 1000 * 60 * 60 * 24);
var dateStr = ninetyDaysAgo.getFullYear() + '-' +
ninetyDaysAgo.getMonth() + '-' +
ninetyDaysAgo.getDate();
//If I print dateStr it's '2017-4-31'
This is important because I need the correct date to use an API. Is this just a thing in the date class or am I missing something?