Solved

Easiest way to show date a file was created on.

Posted on 1998-08-04
12
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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!

 
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
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…

739 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