How the Discord ID is generated
November 2, 2021 ยท View on GitHub
| Field | Bits | Number of bits | Description |
|---|---|---|---|
| Timestamp | 63 to 22 | 42 bits | Milliseconds since Discord Epoch, the first second of 2015 or 1420070400000. |
| Internal worker ID | 21 to 17 | 5 bits | |
| Internal process ID | 16 to 12 | 5 bits | |
| Increment | 11 to 0 | 12 bits | For every ID that is generated on that process, this number is incremented |
How To Convert Discord ID > Date
In Javascript: new Date((id / 4194304) + 1420070400000);
// function found on internet
function getCreationDate(id) {
return new Date((id / 4194304) + 1420070400000);
}
getCreationDate("insertId")
// my own function
const getTime = (id) => {
return ((Number(BigInt.asUintN(64, id) >> 22n)) + 1420070400000) / 1000 | 0
}
getTime("instertId")
Exemple: new Date((622716865428324353 / 4194304) + 1420070400000);
