gpt4 book ai didi

ruby - 从 ruby​​ 中的 UUID v1 中提取时间

转载 作者:数据小太阳 更新时间:2023-10-29 08:05:58 25 4
gpt4 key购买 nike

我存储了以 UUID v1 作为键的数据,现在我想知道 UUID 是什么时候生成的。我该怎么做才好?

最佳答案

这适用于 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

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

关于ruby - 从 ruby​​ 中的 UUID v1 中提取时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6696518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com