Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

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.
0
cide
Asked:
cide
  • 5
  • 4
  • 3
1 Solution
 
cideAuthor Commented:
Edited text of question
0
 
b2piCommented:
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
 
ozoCommented:
Number of days since it was last modified would be
 -M $filename
a readable date would be
 scalar localtime((stat $filename)[9])
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

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.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now