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.