Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > File Modification Date

Reply
Thread Tools

File Modification Date

 
 
Vance M. Allen
Guest
Posts: n/a
 
      09-14-2005
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


 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      09-14-2005
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

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      09-14-2005
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

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      09-14-2005
Vance M. Allen <(E-Mail Removed)> 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
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      09-14-2005
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


 
Reply With Quote
 
Vance M. Allen
Guest
Posts: n/a
 
      09-14-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Vance M. Allen <(E-Mail Removed)> 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
(E-Mail Removed) Perl programming
Fort Worth, Texas


 
Reply With Quote
 
Josef Moellers
Guest
Posts: n/a
 
      09-15-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Last "real" modification date of file Bart Van der Donck Perl Misc 3 06-18-2008 06:01 PM
Using a file's modification date in the filename cca.johnson@gmail.com Perl Misc 3 04-24-2008 03:41 AM
log4j doesn't set file modification date correctly Andy Fish Java 0 07-20-2004 10:20 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Get the date of last modification of a file Manuel Bastioni Python 6 09-09-2003 06:07 PM



Advertisments