Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] How can I get a readable time stamp of a file?

Expand Messages
  • Dan Boger
    ... well, when you stat a file you get a list of values. the ones that have to do with time are: 8 atime last access time since the epoch 9 mtime last
    Message 1 of 2 , Aug 29, 2000
    • 0 Attachment
      On Tue, Aug 29, 2000 at 03:11:55PM -0000, slavik914@... wrote:
      > I would like to print out the time stamp on a file on a UNIX system.
      >
      > I've tried stat and I cant get something that is readable to a
      > regular
      > user. This is probably something that has been asked before here but
      > I cant find it in the archives.
      > I tried perldoc -f stat but either it doesnt explain in plain english
      > or I'm dyslexic.

      well, when you stat a file you get a list of values. the ones that have
      to do with time are:

      8 atime last access time since the epoch
      9 mtime last modify time since the epoch
      10 ctime inode change time (NOT creation time!) since the epoch

      so if you want to know when the file "/foo/bar" was last modified, you'd
      do this:

      $mtime = (stat ("/foo/bar"))[9];

      and to get a human readable for of that, just:

      print scalar localtime($mtime);

      HTH

      Dan
    Your message has been successfully submitted and would be delivered to recipients shortly.