I am currently working with an array of dates and looping through each element. The elements within the array are not date objects but rather strings, I believe.
When I print each of the elements to the console, they appear as follows:
2015,09,19 2015,09,21I am attempting to convert these strings into proper date formats, however, I keep encountering errors stating that the dates are invalid. For example, when I try the following:
var temp = new Date(2015,09,21);
everything works perfectly. But when I attempt to do it dynamically like this:
var temp = new Date(datax[i]);
I receive a message saying "invalid date."
Below is the full loop for reference:
for (var i = 0; i < datax.length; i++) {
var temp = new Date(datax[i]); // fails says invalid date
// var temp = new Date(2015,09,21); //works fine but is statically assigned (want to get it from array)
console.log(temp);
}
Any assistance would be greatly appreciated. Thank you!