gerar data aleatória em um intervalo

function getRandomDate(startDate, endDate) {
    const minValue = startDate.getTime();
    const maxValue = endDate.getTime();
    const timestamp = Math.floor(Math.random() * (maxValue - minValue + 1) + minValue);
    return new Date(timestamp);
}

console.log(getRandomDate(new Date(2020,0,1), new Date(2029,11,31))); // Thu Jun 17 2027 23:13:22 GMT+0200
mentico