Common usage
my $tstamp = time();
my ($y, $m, $d, $ss, $mm, $hh) = (localtime($tstamp))[5,4,3,0,1,2];
$y += 1900;
$m += 1;
A timestamp function
sub tstamp () {
my ($y, $m, $d, $ss, $mm, $hh) = (localtime())[5,4,3,0,1,2];
$y += 1900;
$m += 1;
sprintf("%d%02d%02d%02d%02d%02d", $y, $m, $d, $hh, $mm, $ss);
}
Convert epoch seconds into a human-readable date
$ cat epoch.pl
#!/usr/bin/perl -w
use strict;
use Date::Manip;
my $epoch = $ARGV[0] || time() - 3600 * 24; # yesterday
print "-> epoch = $epoch\n";
my $date = &ParseDateString("epoch $epoch");
print "<- $date\n";
See also:
/perl/date time