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?
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?
モジュールUUID::Tinyには time_of_UUID() というメソッドがあり、これが役立つ場合があります。
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);
この JavaScript API は、UUID を日付形式に変換するのに役立つかもしれません。
この API は、UUID v1 を 1970-01-01 から秒に変換します
あなたが必要とするすべて:
get_time_int = function (uuid_str) {
var uuid_arr = uuid_str.split( '-' ),
time_str = [
uuid_arr[ 2 ].substring( 1 ),
uuid_arr[ 1 ],
uuid_arr[ 0 ]
].join( '' );
return parseInt( time_str, 16 );
};
get_date_obj = function (uuid_str) {
var int_time = this.get_time_int( uuid_str ) - 122192928000000000,
int_millisec = Math.floor( int_time / 10000 );
return new Date( int_millisec );
};
var date_obj = get_date_obj( '8bf1aeb8-6b5b-11e4-95c0-001dba68c1f2' );
date_obj.toLocaleString( );// '11/13/2014, 9:06:06 PM'