Skip to content

Instantly share code, notes, and snippets.

@peerasan
Last active July 23, 2020 03:42
Show Gist options
  • Select an option

  • Save peerasan/61c64a285334d084fde27f374d1f6e67 to your computer and use it in GitHub Desktop.

Select an option

Save peerasan/61c64a285334d084fde27f374d1f6e67 to your computer and use it in GitHub Desktop.
millisecond diff
# Millisecond Difference
# keyword: Millisecond, ms, diff, time, timediff
# Online Perl: https://rextester.com/l/perl_online_compiler, https://www.onlinegdb.com/online_perl_compiler
my $t1 = "00:01:25.652";
my $t2 = "00:01:22.932";
print to_milli($t2) - to_milli($t1);
sub to_milli {
my @components = split /[:\.]/, shift;
return (($components[0] * 60 + $components[1]) * 60 + $components[+2]) * 1000 + $components[3];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment