notes
notes copied to clipboard
MongoDB ObjectId 内的 timestamp 取值范围 or the range of the timestamp in MongoDB ObjectId
情景
当根据指定时间戳生成 ObjectId 时,需要了解 ObjectId 中时间戳的取值范围。
结论
-
ObjectId 是由 24 个十六进制字符(0-f)构成。
-
其中前 8 个字符为时间戳的十六进制值
-
因此其最小值到最大值的范围如下
| 范围 | 时间(UTC) | 时间戳 | 十六进制 |
|---|---|---|---|
| min | 1970-01-01T00:00:00+00:00 | 0 | 0 |
| max | 2106-02-07T06:28:15+00:00 | 4294967295 | ffffffff |