I have two strings which contain time stamps only and look like this - my $t = "2014-11-28 00:00:00.000";
How do I get the time difference between then in readable time (days, hours, minutes, seconds) and not seconds. I am new and I am facing great difficulty in doing this. Each blog or article is telling me to do different things. Some things can't be done because I don't have the modules. I cannot even install the modules into perl because I have many pearl versions on the computer I am working on. So, cpan > install some::modlue does not help.
Please teach me how to do this. Please try to use core perl. Otherwise I will have to spend more time in installing perl modules into the right perl
I made some code to begin with, but its wrong and useless -
use strict;
use warnings;
use Time::Local;
sub secondsToTime{
my $inSeconds = shift;
my $days = int($inSeconds/(24*60*60));
my $hours = ($inSeconds/(60*60))%24;
my $mins = ($inSeconds/60)%60;
my $sec = $inSeconds%60;
my $time = "$days days, $hours hours, $mins mins, $sec seconds";
return $time;
}
# EXAMPLE timelocal( $sec, $min, $hour, $mday, $mon, $year );
my @today = localtime();
print "@today\n";
my $currentTime = timelocal(@today);
#my @t = (0, 00, 13, 28, 11, 2014);
#$currentTime = timelocal(@t);
my @birthday = (0, 00, 12, 28, 11, 2014);
my $birthTime = timelocal(@birthday);
my $sec = ($currentTime - $birthTime);
my $time = secondsToTime($sec);
print "My age = $time\n";