Last active
July 23, 2020 03:42
-
-
Save peerasan/61c64a285334d084fde27f374d1f6e67 to your computer and use it in GitHub Desktop.
millisecond diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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