File Modification Date

V

Vance M. Allen

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
 
J

Josef Moellers

Vance said:
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
 
B

Brian McCauley

Josef said:
perldoc perlfunc
then search for -M

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

perldoc -f -M

See also

perldoc -f stat
 
T

Tad McClellan

Vance M. Allen said:
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
 
J

Jürgen Exner

Vance said:
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
 
V

Vance M. Allen

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


Vance M. Allen said:
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
 
J

Josef Moellers

Vance said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top