Method: BSON::ObjectId#generation_time

Defined in:
lib/bson/object_id.rb

#generation_timeTime

Return the UTC time at which this ObjectId was generated. This may be used instread of a created_at timestamp since this information is always encoded in the object id.

Examples:

Get the generation time.

object_id.generation_time

Returns:

  • (Time)

    The time the id was generated.

Since:

  • 2.0.0



102
103
104
# File 'lib/bson/object_id.rb', line 102

def generation_time
  ::Time.at(to_bson.unpack("N")[0]).utc
end