Search code examples
perlperl-module

How do we convert UUID to date in perl


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

For example, I have UUID like this

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

How to convert this to date format?


Solution

  • 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);
    

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