Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Finding the difference between two dates including milliseconds (Time::Local)

by tye (Sage)
on Jan 10, 2017 at 03:42 UTC ( [id://1179257]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1179257]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found