Is there a way to retroactively create time/node based UUID in PHP?

回眸只為那壹抹淺笑 提交于 2020-01-13 10:16:19

问题


Most time-based (type 1) UUIDs are created using the current time. I'm migrating a MySQL database to cassandra and would like to create timebased UUIDs for archived items. Can someone provide an example of how type-1 UUIDs are created using past time periods?


回答1:


All uuids version 1 are a combination of node identifier (MAC address), timestamp and a random seed.

Yes its possible. The process is reversible.

From RFC4122 about the timestamp part of UUID version 1 (section 4.1.4):

"For UUID version 1, this is represented by Coordinated Universal Time (UTC) as a count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar)."

Basic algorithm (section 4.2.1) for creating time base UUID (uuid version 1)



来源:https://stackoverflow.com/questions/3766009/is-there-a-way-to-retroactively-create-time-node-based-uuid-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!