Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help !!! Easy perl question

Posted on 2001-06-08
7
Medium Priority
?
204 Views
Last Modified: 2010-03-05
I am using the stat function for date of a file however i get a result like -

966152578

i know this is in seconds. but how do i convert it into a readable date - Day , Month , Year

Anant
0
Comment
Question by:anant99
  • 3
  • 2
  • 2
7 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 200 total points
ID: 6167447
$file_date = 966152578;

$formatted_file_date=  localtime($file_date);
# returns a string: Sun Aug 13 17:42:58 2000
print $formatted_file_date;

# or to get all components, $mon will be in the range 0..1, where 0 is January
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($file_date);
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6167482
anant99

please accept an answer in your question on optimization in the cgi area.

Bob
0
 
LVL 1

Author Comment

by:anant99
ID: 6167739
dear teraplane ,

but i want only day , month and year. not the rest

Anant

bebonham - i have accepted an answer
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!

 
LVL 1

Author Comment

by:anant99
ID: 6167768
thanks

Anant
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6168044
thanks anant, I didn't not mean that you should select mine, because I was clearly wrong, I was hoping you would have accepted Sapa's answer.

thanks for closing the question, however.
0
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 6170112
Taking an array slice will let you look at the 3 values only

($mday,$mon,$year) = (localtime($file_date))[3,4,5];
$year += 1900;
print "day: $mday month: $mon year: $year";
0
 
LVL 1

Author Comment

by:anant99
ID: 6170220
bebonham - i accepted your because of your home made recipe not because of the array stuff... As my question was about optimization and not array(array was juat an example).

teraplane - i figured that out. thanks anyway.

Anant
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
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…
Six Sigma Control Plans
Suggested Courses

810 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