【问题标题】:Extract time from a UUID v1 in ruby从 ruby​​ 中的 UUID v1 中提取时间
【发布时间】:2011-07-14 16:16:50
【问题描述】:

我存储了以 UUID v1 作为键的数据,现在我想知道 UUID 是何时生成的。我该如何做到这一点?

【问题讨论】:

标签: ruby time uuid


【解决方案1】:

这适用于 irb:

require 'simple_uuid'
uuid = SimpleUUID::UUID.new
uuid.to_guid # actually this is what I have stored in my database
Time.at(SimpleUUID::UUID.new(uuid.to_guid).seconds) # returns the time and date of the UUID

感谢我的朋友 KillerFox,他向我展示了简单的解决方案。

【讨论】:

    猜你喜欢
    • 2013-07-08
    • 1970-01-01
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    • 2016-08-10
    • 2018-04-17
    相关资源
    最近更新 更多