• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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