Method: BSON::ObjectId.timestamp

Defined in:
lib/bson/object_id.rb

.timestampInteger

Note:

This value is guaranteed to be no more than 4 bytes in length. A time value far enough in the future to require a larger integer than 4 bytes will be truncated to 4 bytes.

Returns an integer timestamp (seconds since the Epoch). Primarily used by the generator to produce object ids.

Returns:

  • (Integer)

    the number of seconds since the Epoch.

Since:

  • 2.0.0



373
374
375
# File 'lib/bson/object_id.rb', line 373

def timestamp
  ::Time.now.to_i % MAX_INTEGER
end