in reply to Date conversion

Or without modules:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time +); $year += 1900; $mon += 1; print join '_', ($year,$mon,$mday,$hour,$min,$sec); # YYYY_MM_DD_HH_M +M_SS
Comment: It does not print values less than 10 with a leading zero. If you need that, it can be easily added. It is left as an exercise for the reader.

Update: Added $mon += 1. Thanks graff

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re: Re: Date conversion
by graff (Chancellor) on Mar 25, 2004 at 02:11 UTC
    You forgot to add one to $mon -- localtime() returns January as "0".
Re: Re: Date conversion
by halley (Prior) on Mar 25, 2004 at 15:04 UTC
    He didn't say he had Unix epoch numerical times, or wanted the output of time(). He said he had strings in a given format, and wanted them in a different format.

    --
    [ e d @ h a l l e y . c c ]

      You're right, I jumped to conclusions. Mea culpa

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law