Last active
February 14, 2024 01:54
-
-
Save dotproto/ae4eead8f7a97620e963 to your computer and use it in GitHub Desktop.
Convert a Firebase Push ID into Unix time (https://gist.github.com/mikelehen/3596a30bd69384624c11/)
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 getPushIdTimestamp = (function getPushIdTimestamp() { | |
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; | |
return function getTimestampFromId(id) { | |
var time = 0; | |
var data = id.substr(0, 8); | |
for (var i = 0; i < 8; i++) { | |
time = time * 64 + PUSH_CHARS.indexOf(data[i]); | |
} | |
return time; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python 2.X/3.X port: