Solved

Easiest way to show date a file was created on.

Posted on 1998-08-04
12
160 Views
Last Modified: 2010-03-05
Hi,
     What is the easist way to show the date a file was created on?

Thanks in Advance.
0
Comment
Question by:cide
  • 5
  • 4
  • 3
12 Comments
 

Author Comment

by:cide
ID: 1209010
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 10 total points
ID: 1209011
You can't get the date a file was created on, just the date that it was last saved on.  This, however, will give you the number of days since the file was modified

($^T-(stat $filename)[9])/(60*60*24)

Then, you can use DateCalc in Date::Manip to convert that into a readable date.

0
 
LVL 84

Expert Comment

by:ozo
ID: 1209012
Number of days since it was last modified would be
 -M $filename
a readable date would be
 scalar localtime((stat $filename)[9])
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1209013
ozo, are you sure that -M works on win32?  I had thought that there might be bugs with it...
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209014
It seems to work the same as ($^T-(stat $filename)[9])/(60*60*24)
What version are you using?
0
 

Author Comment

by:cide
ID: 1209015
Then you do you use Date::Manip?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 84

Expert Comment

by:ozo
ID: 1209016
What do you want to do with Date::Manip?
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1209017
perldoc Date::manip

Look at UnixDate

0
 

Author Comment

by:cide
ID: 1209018
I want to show dd/mm/yy.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209019
($d,$m,$y) = (localtime((stat $filename)[9]))[3,4,5];
$m+=1; $y+=1900;
printf("%02d/%02d/%d\n",$d,$m,$y);

use Date::Manip;
print &UnixDate(scalar localtime((stat $filename)[9]),"%d/%m/%Y");
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209020
use POSIX;
print strftime"%d/%m/%Y",localtime((stat $filename)[9]);
0
 

Author Comment

by:cide
ID: 1209021
Thank you would you like the points ozo?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
A short film showing how OnPage and Connectwise integration works.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now