problem with time stamp

D

davide.papagno

Hi all.
I use this command to get the time stamp file output

$date = ctime(stat($file)->mtime);

and what I get is:

Wed Apr 5 16:44:43 2006

is there a simple way to get only

Wed Apr 5
?

really thanx all
 
D

davide.papagno

Yeah Tony, it seems is great

$now = strftime "%a %b %d", gmtime;
print "$now\n";

But I have to get the time stamp of a file $file.
I don't know how to match strftime and stat function

Tony Curtis ha scritto:
 
T

Tony Curtis

On 13 Jul 2006 07:08:07 -0700,
Yeah Tony, it seems is great $now = strftime "%a %b %d",
gmtime; print "$now\n";
But I have to get the time stamp of a file $file. I
don't know how to match strftime and stat function

Ah well, couldn't give it all away, could I? :)

localtime()

hth
t
 
D

DJ Stunks

Tony said:
Ah well, couldn't give it all away, could I? :)

localtime()

or use Date::Format instead of POSIX...

C:\tmp>perl -MDate::Format -e "print time2str '%a %b %d', (stat
'tmp.txt')[9]"
Tue Jul 11

-jp
 
J

John W. Krahn

I use this command to get the time stamp file output

$date = ctime(stat($file)->mtime);

According to my ctime(3) man page: "The call ctime(t) is equivalent to
asctime(localtime(t))." and in perl localtime() in scalar context is the same
as C's asctime(localtime(t)) so you don't really need ctime there:

$date = localtime stat( $file )->mtime;

and what I get is:

Wed Apr 5 16:44:43 2006

is there a simple way to get only

Wed Apr 5

$date = substr localtime stat( $file )->mtime, 0, 10;



John
 
D

davide.papagno

GREAT!!!
Thanx all!!


John W. Krahn ha scritto:
According to my ctime(3) man page: "The call ctime(t) is equivalent to
asctime(localtime(t))." and in perl localtime() in scalar context is the same
as C's asctime(localtime(t)) so you don't really need ctime there:

$date = localtime stat( $file )->mtime;



$date = substr localtime stat( $file )->mtime, 0, 10;



John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top