Created
November 14, 2018 23:06
-
-
Save oscaroceguera/b3656b36fa32d2f8139d498bc239e76b to your computer and use it in GitHub Desktop.
Hashids timestamp
This file contains hidden or 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
const Hashids = require('hashids'); | |
const hashids = new Hashids() | |
const dateTime = Date.now('1985-14-05') | |
const timestamp = Math.floor(dateTime / 1000) | |
console.log('DateTime ===>', dateTime) | |
console.log('Timestamp ===>', timestamp) | |
const encrypted = hashids.encodeHex(timestamp) | |
const decoded = hashids.decodeHex(encrypted) | |
console.log('encrypted ===>', encrypted) | |
console.log('decoded ===>', decoded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment