Perl has a great core module for dealing with dates and times:
use Time::Piece; my $t = localtime(); my $unixtime = $t->epoch(); # Unixtime my $human = $t->cdate(); # Human readable # Format a date/time for output print $t->strftime("%Y-%M-%d") . "\n"; # Convert a specific format to a date/time object my $bd = localtime->strptime("1985-02-14", "%Y-%M-%d"); print "You were born on a " . $bd->fullday . " in " . $bd->year . "\n"; # Date/Time addition print "In one hour it will be: " . (localtime() + 3600)->hms . "\n";
It works by overriding the built in
gmtime() functions and giving them an object oriented interface. I highly recommend looking at it if you have to deal with dates and times.