notes icon indicating copy to clipboard operation
notes copied to clipboard

MongoDB ObjectId 内的 timestamp 取值范围 or the range of the timestamp in MongoDB ObjectId

Open lanlin opened this issue 4 years ago • 0 comments

情景

当根据指定时间戳生成 ObjectId 时,需要了解 ObjectId 中时间戳的取值范围。

结论

  1. ObjectId 是由 24 个十六进制字符(0-f)构成。

  2. 其中前 8 个字符为时间戳的十六进制值

  3. 因此其最小值到最大值的范围如下

范围 时间(UTC) 时间戳 十六进制
min 1970-01-01T00:00:00+00:00 0 0
max 2106-02-07T06:28:15+00:00 4294967295 ffffffff

lanlin avatar Nov 22 '21 11:11 lanlin