Solved

Help !!! Easy perl question

Posted on 2001-06-08
7
160 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

20 Experts available now in Live!

Get 1:1 Help Now