Skip to content

Instantly share code, notes, and snippets.

@jsmithdev
Created June 11, 2019 19:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmithdev/1f31f9f3912d40f6b60bdc7e8098ee9f to your computer and use it in GitHub Desktop.
Save jsmithdev/1f31f9f3912d40f6b60bdc7e8098ee9f to your computer and use it in GitHub Desktop.
function createUUID(){
let dt = new Date().getTime()
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = (dt + Math.random()*16)%16 | 0
dt = Math.floor(dt/16)
return (c=='x' ? r :(r&0x3|0x8)).toString(16)
})
return uuid
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment