I have a code where I am trying to generate random dates, but the timezone is always included and I'm not sure how to remove it. Can someone assist me with this? I am new to coding, so any help would be greatly appreciated! Thank you.
var startDate = new Date("1990-01-01");
var endDate = new Date("2022-01-01");
function formatDate(date) {
const year = date.getFullYear();
/* getMonth returns dates from 0, so add one */
const month = date.getMonth() + 1;
const day = date.getDate();
return `${year}-${month < 10 ? '0' : ''}${ month }-${ day < 10 ? '0' : '' }${day}`
}
var getDateArray = function(start, end) {
return new Date(
start.getTime() + Math.random() * (end.getTime(0) - start.getTime(0))
);
}
var dateArr = getDateArray(startDate, endDate);
console.log(dateArr);