Solved

Help !!! Easy perl question

Posted on 2001-06-08
7
188 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 50 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
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 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

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!

Question has a verified solution.

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

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

705 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