Created
May 9, 2024 08:36
-
-
Save mikaelvesavuori/a6ddc36def7680911dfadd8f0ce185b8 to your computer and use it in GitHub Desktop.
Example of ULID to replace timestamps.
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
import { ulid, decodeTime } from 'ulidx'; | |
const timestamp = () => parseInt(Date.now().toString()); | |
const time = timestamp(); | |
const ulidTime = ulid(time); | |
console.log('timestamp', time); | |
console.log('ulid', ulidTime); | |
console.log('ulid timestamp', decodeTime(ulidTime)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment