in reply to time difference in milliseconds
Split on ':' and '.', then convert to measurement in pure-millisecond, then do a minus (assume this is always the same day)
my $t1 = "05:07:53.249"; my $t2 = "05:07:55.401"; 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]; }
|
|---|