Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Easiest way to show date a file was created on.

Posted on 1998-08-04
12
Medium Priority
?
190 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 20 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Six Sigma Control Plans

715 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