Easiest way to show date a file was created on.

Hi,
     What is the easist way to show the date a file was created on?

Thanks in Advance.
cideAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
b2piConnect With a Mentor Commented:
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
 
cideAuthor Commented:
Edited text of question
0
 
ozoCommented:
Number of days since it was last modified would be
 -M $filename
a readable date would be
 scalar localtime((stat $filename)[9])
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
b2piCommented:
ozo, are you sure that -M works on win32?  I had thought that there might be bugs with it...
0
 
ozoCommented:
It seems to work the same as ($^T-(stat $filename)[9])/(60*60*24)
What version are you using?
0
 
cideAuthor Commented:
Then you do you use Date::Manip?
0
 
ozoCommented:
What do you want to do with Date::Manip?
0
 
b2piCommented:
perldoc Date::manip

Look at UnixDate

0
 
cideAuthor Commented:
I want to show dd/mm/yy.
0
 
ozoCommented:
($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
 
ozoCommented:
use POSIX;
print strftime"%d/%m/%Y",localtime((stat $filename)[9]);
0
 
cideAuthor Commented:
Thank you would you like the points ozo?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.