Skip to content

Instantly share code, notes, and snippets.

@barokurniawan
Created October 27, 2020 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barokurniawan/13a75b11007de846b715b17a159a7eb6 to your computer and use it in GitHub Desktop.
Save barokurniawan/13a75b11007de846b715b17a159a7eb6 to your computer and use it in GitHub Desktop.
uniqid.js just like uniqid in PHP
function uniqid(a = "",b = false){
var c = Date.now()/1000;
var d = c.toString(16).split(".").join("");
while(d.length < 14){
d += "0";
}
var e = "";
if(b){
e = ".";
var f = Math.round(Math.random()*100000000);
e += f;
}
return a + d + e;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment