Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active December 21, 2022 16:27
Show Gist options
  • Star 37 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save miguelmota/5b67e03845d840c949c4 to your computer and use it in GitHub Desktop.
Save miguelmota/5b67e03845d840c949c4 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()))
@saltarin
Copy link

nice memes

@vedro-compota
Copy link

thanks!

@gawdeparag
Copy link

Thanks for this! Saved my day!!

@thomas-avada
Copy link

Not all heroes wear capes

@Ainika-Kos
Copy link

Thank you! ;)

@Alphavader
Copy link

Thanks man!

@arthursvpb
Copy link

very useful! thanks.

@giovponce
Copy link

good vibes to you!

@Heunsig
Copy link

Heunsig commented Nov 8, 2022

Thank you!

@DidarHalla
Copy link

Good job, but i don't understand, how it's work.... Please explain)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment