Forked from skrrp/gist:c719e07979b86e5fb96f010c563ac455
Created
September 3, 2019 12:47
-
-
Save DmitryMarkov/b7e71387c244c2894971a7a0efbe5116 to your computer and use it in GitHub Desktop.
javascript ObjectId generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoObjectId = function () { | |
var timestamp = (new Date().getTime() / 1000 | 0).toString(16); | |
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() { | |
return (Math.random() * 16 | 0).toString(16); | |
}).toLowerCase(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment