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

Re^3: How do I tell the time between two dates?

by kevbot (Vicar)
on Apr 16, 2016 at 06:04 UTC ( [id://1160607]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How do I tell the time between two dates?
in thread How do I tell the time between two dates?

The Time::Duration module has the functionality you need. For example,
#!/usr/bin/env perl use strict; use warnings; use Time::Piece; use Time::Duration; my $date_format = '%Y-%m-%d'; my $hiredate = Time::Piece->strptime('2014-05-05', $date_format ); my $nowdate = Time::Piece->strptime('2016-04-15', $date_format ); my $elapsed_seconds = $nowdate - $hiredate; print " Hire Date: $hiredate\n"; print " Now Date: $nowdate\n"; print "It has been ", duration($elapsed_seconds), " since you were hir +ed.\n"; exit;
See Is there a CPAN module for converting seconds to English? for a helpful discussion on this topic.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (None)
    As of 2024-04-25 02:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found