From 140c8fc8020f677c9326103a7cb718ae482e0226 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Wed, 12 Jul 2017 15:36:45 +0100 Subject: Improve handling of milliseconds to handle any length --- unixtime.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'unixtime.pl') diff --git a/unixtime.pl b/unixtime.pl index d6fff26..e75a786 100755 --- a/unixtime.pl +++ b/unixtime.pl @@ -12,8 +12,8 @@ if (@ARGV eq 1) { if (defined $args[0] and $args[0] ne "") { if ($args[1] eq "ms") { #Convert from timestamp in milliseconds to date - $seconds = substr $args[0], 0, 10; - $milliseconds = substr $args[0], 10, 3; + $seconds = substr $args[0], 0, -3; + $milliseconds = substr $args[0], -3; $date = strftime('%a %b %e %H:%M:%S:' . $milliseconds . ' %Z %Y', localtime( $seconds ) ) . "\n"; print $date; } elsif ($args[0] eq "ms") { -- cgit v1.2.3