我们如何在Perl中将UUID转换为日期 [英] How do we convert UUID to date in perl

查看:145
本文介绍了我们如何在Perl中将UUID转换为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Perl语言很陌生.如何将UUID转换为日期格式2011-04-22?

I am very new to Perl language. How to convert the UUID to date format 2011-04-22 ?

例如,我有这样的UUID

For example, I have UUID like this

118ffe80-466b-11e1-b5a5-5732cf729524.

如何将其转换为日期格式?

How to convert this to date format?

推荐答案

模块 UUID :: Tiny 具有一个名为time_of_UUID()的方法,该方法可能会有所帮助:

The module UUID::Tiny has a method called time_of_UUID() that might help:

time_of_UUID()

This function accepts UUIDs and UUID strings. 
Returns the time as a   floating point value, so use int() 
to get a time() compatible value.

Returns undef if the UUID is not version 1.

my $uuid_time = time_of_UUID($uuid);


RFC4122 的时间戳记"部分也可以补充维基百科有关UUID的文章.

The Timestamp section of RFC4122 can also complement the Wikipedia article about UUID.

这篇关于我们如何在Perl中将UUID转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆