Skip to content

Instantly share code, notes, and snippets.

@oscaroceguera
Created November 14, 2018 23:06
Show Gist options
  • Save oscaroceguera/b3656b36fa32d2f8139d498bc239e76b to your computer and use it in GitHub Desktop.
Save oscaroceguera/b3656b36fa32d2f8139d498bc239e76b to your computer and use it in GitHub Desktop.
Hashids timestamp
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