http://qs321.pair.com?node_id=1179257


in reply to Finding the difference between two dates including milliseconds

So simple to do with minimal prerequisites (one core module, Time::Local):

use Time::Local qw< timegm >; while( <> ) { my @when = split /,\s*/, $_; for( @when ) { my @parts = /([0-9]+)/g; $_ = timegm( reverse( $parts[0]-1900, $parts[1]-1, @parts[2..5 +] ) ); $_ += "0.$parts[6]"; } print $when[0] - $when[1], $/; } __END__ 2017-01-09 05:08:04.575804, 2017-01-09 05:08:04.319338 2017-01-09 05:08:17.093719, 2017-01-09 05:08:16.840292 2017-01-09 05:12:48.629407, 2017-01-09 05:12:48.372687 2017-01-09 05:13:25.315665, 2017-01-09 05:13:25.061834 2017-01-09 05:14:08.171994, 2017-01-09 05:14:07.916187 2017-01-09 05:17:03.182747, 2017-01-09 05:17:02.929309 2017-01-09 05:18:46.561289, 2017-01-09 05:18:46.305743 2017-01-09 05:19:09.772227, 2017-01-09 05:19:09.518975 __END__ 0.256465911865234 0.253427028656006 0.256719827651978 0.253830909729004 0.255806922912598 0.253437995910645 0.255546092987061 0.253252029418945

- tye        

  • Comment on Re: Finding the difference between two dates including milliseconds (Time::Local)
  • Download Code