I am trying to create an object with all the dates from "today" until 60 days from now.
My code:
var dates = [];
getDateRange();
function getDateRange() {
var today = new Date();
var date = new Date();
for (var i = 0; i <= 59; i++) {
date.setDate(today.getDate()+i);
console.log(date);
dates[i] = date;
};
console.log(dates);
}
Prints out the dates correctly with the "console.log(date)" command, as follows:
Mon Jun 15 2015 21:31:47 GMT+0200
Tue Jun 16 2015 21:31:47 GMT+0200
Wed Jun 17 2015 21:31:47 GMT+0200
Thu Jun 18 2015 21:31:47 GMT+0200
Fri Jun 19 2015 21:31:47 GMT+0200
...
But once it is put into the dates array and printed out I get the following array of dates:
[Wed Jan 03 2024 21:42:47 GMT+0100,
Wed Jan 03 2024 21:42:47 GMT+0100,
Wed Jan 03 2024 21:42:47 GMT+0100,
Wed Jan 03 2024 21:42:47 GMT+0100,
...,
Wed Jan 03 2024 21:42:47 GMT+0100
]
I hope I explained the problem well.
The code is part of an AngularJS app but I think my problem has to do only with Javascript.