Solved

Easiest way to show date a file was created on.

Posted on 1998-08-04
12
151 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

746 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now