diff options
author | Joe Robinson <joe@lc8n.com> | 2017-07-12 15:36:45 +0100 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2017-07-12 15:36:45 +0100 |
commit | 140c8fc8020f677c9326103a7cb718ae482e0226 (patch) | |
tree | b0ed1bffcc2920bc5fc2027d9d45c84e30e5a046 | |
parent | ec1620e57b8ea542ccd8e703539bc14c3e2cf40e (diff) |
Improve handling of milliseconds to handle any length
-rwxr-xr-x | unixtime.pl | 4 |
1 files changed, 2 insertions, 2 deletions
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") { |