Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Random date in JavaScript
function randomDate(start, end) {
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
console.log(randomDate(new Date(2012, 0, 1), new Date()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment