http://www.perlmonks.org?node_id=627886

punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:

Maverick Monks,

This snippet:

$file_w_path = "../../../images/".$filename; ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, +$ctime, $blksize, $blocks) = stat($file_w_path); print "<br>mtime = $mtime\n"; ($sec, $min, $hr, $day, $month, $year, $day_Of_Week, $julianDate, $dst +) = localtime($mtime); print "<br>$sec, $min, $hr, $day, $month, $year, $day_Of_Week, $julian +Date, $dst\n";
produces this output:
1182819156 Time::tm=ARRAY(0x84eb290), , , , , , , ,
where 1182819156 is the correct epoch time for the file, but I can't make sense of the localtime output. Clearly I'm using localtime wrong...and yet,

http://perldoc.perl.org/functions/localtime.html

localtime

Converts a time as returned by the time function to a 9-element list with the time analyzed for the local time zone. Typically used as follows:

# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

Thanks.




Forget that fear of gravity,
Get a little savagery in your life.