Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

with $stat9 which displays the date and time and stuff. How can I make it just display the date

Replies are listed 'Best First'.
Re: stat function ? number two
by Abigail-II (Bishop) on Jun 12, 2002 at 15:33 UTC
    The time returned is in seconds since the epoch. It only displays date and time if you translate it to a date and time. If you don't want to have the time, then don't do that!

    You might want to investigate the POSIX::strftime function.

    Abigail

      can't I do it with localhost
        I mean localtime
Re: stat function ? number two
by Joost (Canon) on Jun 12, 2002 at 15:54 UTC
    Read the docs on localtime.

    You can do this with perldoc -f localtime

    You will (amongs a lot of very useful information) see an example of Abigail's suggestion (strftime):

    use POSIX qw(strftime); $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;

    Adapting this piece of code to your needs is left as an exercise.

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
Re: stat function ? number two
by GhodMode (Pilgrim) on Jun 12, 2002 at 16:09 UTC
         Here's how I do it...
    use POSIX 'strftime'; open (FILE, "file.txt"); my $filedate = strftime('%m%d%Y', localtime( (lstat(FILE))[9] ));
    Vince
      Im j/w is there a way to do it withought use POSIX