Skip to content

Instantly share code, notes, and snippets.

@NicholasKuchiniski
Forked from miguelmota/randomDate.js
Created June 9, 2018 22:45
Show Gist options
  • Save NicholasKuchiniski/20b373d6621c69c8f00777c171a331c9 to your computer and use it in GitHub Desktop.
Save NicholasKuchiniski/20b373d6621c69c8f00777c171a331c9 to your computer and use it in GitHub Desktop.
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