I am trying to convert a variable in Perl that contains milliseconds to date/time format. The catch is that variable came from mainframe TIMESTAMP that can not be converted by Unix/Linux because the duration, if I am not mistaken, starts in 1900-01-01 00:00:00. Thanks in advance.
perl:
my $milli_secs = ((hex(unpack('H*', substr($updt_time,0,3))) * 1099511627776) +
(hex(unpack('H*', substr($updt_time,3,3))) * 65536) +
(hex(unpack('H*', substr($updt_time,6,2)))));
$milli_secs = $milli_secs / 16;
$milli_secs = ($milli_secs * 3.90625) / 1000000;
print "$milli_secs\n";
my $tp = DateTime->from_epoch( epoch => $milli_secs );
print "Date ==> $tp\n";
Result: 3747753982164.99 Date ==> 120731-08-07T04:49:24
My variables: EBCDIC timestamp: D508FF8D00000000 With some calculations I have: Nano seconds: 3.74775398216499e+18 Milliseconds: 3747753982164.99
Which should give me (I think): 2018-10-05 18:46:22.1