File Modification Date

Discussion in 'Perl Misc' started by Vance M. Allen, Sep 14, 2005.

  1. I'm trying to find out how to determine the date and/or time that a file was
    created in a simple procedure. I have heard about a few different libraries
    but the examples I have found haven't been very useful.

    The basic purpose I want to do is a simple footer provided by a package
    module through CGI to inform users of the latest update to the code based on
    the URL. Something simple saying "Version x.xx, Last Modified MM/DD/YYYY."
    which would automatically get the file modified timestamp.

    I'd prefer to have, if possible, a simple scalar variable to store the
    date...for example:

    $modtime = filemoddate_func(filename.cgi);

    If anyone can help me with the libraries I need to use for this (if any
    special), and a code snippet if possible, I'd really appreciate it.

    Thanks!

    Vance
     
    Vance M. Allen, Sep 14, 2005
    #1
    1. Advertising

  2. Vance M. Allen wrote:
    > I'm trying to find out how to determine the date and/or time that a file was
    > created in a simple procedure. I have heard about a few different libraries
    > but the examples I have found haven't been very useful.
    >
    > The basic purpose I want to do is a simple footer provided by a package
    > module through CGI to inform users of the latest update to the code based on
    > the URL. Something simple saying "Version x.xx, Last Modified MM/DD/YYYY."
    > which would automatically get the file modified timestamp.
    >
    > I'd prefer to have, if possible, a simple scalar variable to store the
    > date...for example:
    >
    > $modtime = filemoddate_func(filename.cgi);
    >
    > If anyone can help me with the libraries I need to use for this (if any
    > special), and a code snippet if possible, I'd really appreciate it.


    perldoc perlfunc
    then search for -M

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Moellers, Sep 14, 2005
    #2
    1. Advertising

  3. Josef Moellers wrote:

    > perldoc perlfunc
    > then search for -M


    Actually, although it seems counter-intuative, you _can_ do:

    perldoc -f -M

    See also

    perldoc -f stat
     
    Brian McCauley, Sep 14, 2005
    #3
  4. Vance M. Allen <> wrote:

    > Subject: File Modification Date

    ^^^^^^^^^^^^

    > date and/or time that a file was
    > created

    ^^^^^^^

    > the file modified timestamp.

    ^^^^^^^^


    Modified: 2
    Created: 1

    Which is it?

    Many filesystems do not keep track of when a file is created.


    > If anyone can help me with the libraries



    You don't need _any_ libraries to get the modified time stamp:

    perldoc -f stat

    see also:

    perldoc -f -X

    and maybe:

    perldoc -f localtime


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Sep 14, 2005
    #4
  5. Vance M. Allen wrote:
    > I'm trying to find out how to determine the date and/or time that a
    > file was created in a simple procedure.


    Are you looking for stat()?
    [...]
    8 atime last access time in seconds since the epoch
    9 mtime last modify time in seconds since the epoch
    10 ctime inode change time (NOT creation time!) in seconds
    since
    the epoch

    jue
     
    Jürgen Exner, Sep 14, 2005
    #5
  6. Sorry for the confusion; for this project, I needed the modification date,
    but if anyone knows how to get the creation date too, that's great. I'm
    using the standard ext3 filesystem.

    I was successful through the help provided here to get the modification
    date/time. Thanks for everyone's input.

    Vance


    "Tad McClellan" <> wrote in message
    news:...
    Vance M. Allen <> wrote:

    > Subject: File Modification Date

    ^^^^^^^^^^^^

    > date and/or time that a file was
    > created

    ^^^^^^^

    > the file modified timestamp.

    ^^^^^^^^


    Modified: 2
    Created: 1

    Which is it?

    Many filesystems do not keep track of when a file is created.


    > If anyone can help me with the libraries



    You don't need _any_ libraries to get the modified time stamp:

    perldoc -f stat

    see also:

    perldoc -f -X

    and maybe:

    perldoc -f localtime


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Vance M. Allen, Sep 14, 2005
    #6
  7. Vance M. Allen wrote:
    > Sorry for the confusion; for this project, I needed the modification date,
    > but if anyone knows how to get the creation date too, that's great. I'm


    You're not really asking that question, do you, since

    "Tad McClellan" <> wrote in message
    news:...

    > perldoc -f stat
    > perldoc -f -X
    > perldoc -f localtime


    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Moellers, Sep 15, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,308
    Michael Borgwardt
    May 30, 2004
  2. Andy Fish
    Replies:
    0
    Views:
    629
    Andy Fish
    Jul 20, 2004
  3. Manuel Bastioni

    Get the date of last modification of a file

    Manuel Bastioni, Sep 8, 2003, in forum: Python
    Replies:
    6
    Views:
    2,066
    Manuel Bastioni
    Sep 9, 2003
  4. Replies:
    3
    Views:
    151
  5. Bart Van der Donck

    Last "real" modification date of file

    Bart Van der Donck, Jun 18, 2008, in forum: Perl Misc
    Replies:
    3
    Views:
    176
    Bart Van der Donck
    Jun 18, 2008
Loading...

Share This Page