?
Solved

Help !!! Easy perl question

Posted on 2001-06-08
7
Medium Priority
?
192 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
[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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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
Suggested Courses

765 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