Skip to content

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

Open

Description

@lanlin

情景

当根据指定时间戳生成 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions