SPUG: File dates
Ken McGlothlen
mcglk at serv.net
Thu Dec 30 12:22:27 CST 1999
"Daniel V. Ebert" <debert at dusya.osd.com> writes:
| ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
| $ctime, $blksize, $blocks) = stat FILEHANDLE;
|
| This returns the time in a numrical format: 946568470
| I'm guessing that this is the number of seconds since the epoch ... is there
| an easy way to translate that into a calendar date? Or is there a different
| command that would return the modify time in a different format?
Fortunately yes.
First, there's always localtime. You can call this in three ways:
($sc, $mn, $hr, $md, $mo, $yr, $wd, $yd, $dst) = localtime( $mtime );
returns (in order) seconds, minutes, hours, day of month, month (from 0), year
(offset from 1900), weekday (0 through 6), day of year (from 0), and a boolean
telling you if DST is on or not.
Alternatively, you could do:
$now = localtime( $mtime );
and $now will be "Thu Dec 30 10:21:53 1999" (a la ctime(3)).
There's also a gmttime() function that does the same thing, only in GMT.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list