I want to generate a random date between two dates and between two times in javascript. For instance I want to generate a random date (between 8 am and 6 pm) between today and next tomorrow. I have tried a whole bunch of things but none of them work so I won't be pasting any code since it does not work. Has anyone done something similar
function generateRandomDate(start, end) {
return new Date(start + Math.random() * (end - start));
}
The code I am using for generating random dates is posted above