Constructor
Configuration Item
OptionaldatacenterId?: numberData Center ID
Optionalepoch?: numberdefault start time: 2025-01-01 00:00:00Z / 1735660800000
OptionalworkerId?: numberWork Node ID
PrivatedatacenterData center ID (0~31)
Private ReadonlydatacenterThe number of bits occupied by the data identifier ID
Private ReadonlydatacenterThe data identification ID is shifted left by 17 bits (12+5).
PrivateepochStart time cut-off (2025-01-01 00:00:00)
PrivatelastThe timestamp of the last generated ID
Private ReadonlyMAX_Private ReadonlymaxThe maximum supported data identifier ID
Private ReadonlymaxMaximum supported machine ID
PrivatesequenceMillisecond sequence (0~4095)
Private ReadonlysequenceThe number of digits occupied by the sequence in the ID
Private ReadonlysequenceGenerate a mask for the sequence, here it is 4095 (0b111111111111=0xfff=4095)
Private ReadonlytimestampThe time is shifted left by 22 bits (5+5+12)
Private ReadonlytotalPrivateworkerWork machine ID (0~31)
Private ReadonlyworkerThe number of bits occupied by the machine ID
Private ReadonlyworkerThe machine ID shifts left by 12 bits.
Generate the next ID
64-bit ID
Analyze ID
64-bit ID
Analysis results with:
timestamp: Milliseconds since epochdatacenterId: Datacenter ID part of the Snowflake IDworkerId: Worker node ID part of the Snowflake IDsequence: Sequence number for IDs generated in the same millisecondPrivatetilBlock until the next millisecond, until a new timestamp is obtained.
The timestamp of the last generated ID
Current timestamp
Twitter's distributed auto-increment ID snowflake algorithm(https://github.com/twitter/snowflake),
default start time:
2025-01-01 00:00:00Z / 1735660800000
Example
See
https://utils.selize.snroe.com/classes/uuid_snowflake.Snowflake.html